NancyJ
09-09-2006, 03:42 PM
If you have an enum field, is it possible to get a list of all the values?
|
||||
EnumNancyJ 09-09-2006, 03:42 PM If you have an enum field, is it possible to get a list of all the values? Fumigator 09-09-2006, 06:04 PM The manual suggests: If you want to determine all possible values for an ENUM column, use SHOW COLUMNS FROM tbl_name LIKE enum_col and parse the ENUM definition in the Type column of the output. NancyJ 09-09-2006, 06:07 PM For anyone else wondering - I also found in the comments this nifty little function $result = mysql_query("SHOW COLUMNS FROM <table>"); // Makes arrays out of all ENUM type fields. // Uses the field names as array names and skips non-ENUM fields while( $row = mysql_fetch_row($result) ) { extract($row); if (substr($Type, 0, 4) != 'enum') continue; $Type = str_replace('enum', 'array', $Type); // Make array eval("$" . $Field . " = " . $Type); } |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum