note 30827 deleted from function.mysql-query by didou
| From: | didou@php.net | Date: | Sat, 16 Aug 2003 09:28:30 +0000 |
| Subject: | note 30827 deleted from function.mysql-query by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54305@lists.php.net to get a copy of this message | ||
Note Submitter: gmalcolmSPAM@BADprofessionalcredit.com
----
An addition to the useful post on converting enums to select by claude_minette. This function
returns an array for all possible values of a mysql enum field. I needed this to separate display
from content.
//presumes db connection
function listEnum($dbtable, $fieldname){
$describe = mysql_fetch_assoc("describe $dbtable");
while ($line=mysql_fetch_assoc($describe)){
extract($line);
if($Type != "enum" and $Field != $fieldname){continue;}
preg_match_all("/'(\w+)'/",$Type,$choices);
break;
}
//return only individual matches
return $choices[1];
}