7 Mar 2011

Retrieving MySQL enum values in PHP

Retrieve an array of all the available enum values.
if ($result = mysql_query("SHOW COLUMNS FROM {$table} LIKE '{$column}'))
{
  $enum = mysql_fetch_object($result);
  preg_match_all("/'([\w ]*)'/", $enum->Type, $values);
}

No comments: