|
Thanks for your input. I think I now have the answer to my question. A code like this will return the enum values for a given field either as string or as array:
function getEnumsAsString($table,$field)
{
$query="SHOW COLUMNS FROM " . $table . " LIKE '" . $field . "'";
$result=mysql_query($query);
$enumvals = mysql_result($result, 0, "Type");
//echo "Enum values: $enumvals<br><br>";
return $enumvals;
}
function getEnumsAsArray($table,$field)
{
$str=$this->getEnumsAsString($table,$field);
$str1=preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$str); //echo $str1;
$options=explode("','",$str1); //print_r($options);
return $options;
}
|