note 34181 added to function.mysql-fetch-field
| From: | creak at foolstep dot com | Date: | Thu, 17 Jul 2003 20:05:09 +0000 |
| Subject: | note 34181 added to function.mysql-fetch-field | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52293@lists.php.net to get a copy of this message | ||
I think i've found a good way to separate the type and its length, for examples :
- "int(11)" has type "int" and length "11"
- "enum('N','Y')" has type "enum" and length
"'N', 'Y'"
[CODE]
$result = mysql_query("DESC users", $link_id);
while ($data = mysql_fetch_array($result)) {
ereg("([a-zA-Z]+)\((.+)\)", $data['Type'], $type);
// $type[1] <=> type
// $type[2] <=> length
}
mysql_free_result($result);
[/CODE]
The ereg() function is shorter but i think it can handle quite all types :)
By the way, why is there so few tuts about the pattern possibility for the ereg() function ?
Creak
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-field.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34181
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34181&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34181&report=yes