note 26452 added to function.mysql-field-flags

From: Date: Thu, 31 Oct 2002 06:32:45 +0000
Subject: note 26452 added to function.mysql-field-flags
Groups: php.notes 
Request: Send a blank email to php-notes+get-38815@lists.php.net to get a copy of this message
I didn't find anything to get the valid values for ENUM or SET column types, so I came up with the following function mysql_enum_values($table, $field) { $sql = "SHOW COLUMNS FROM $table LIKE '$field'"; $sql_res = mysql_query($sql) or die("Could not query:\n$sql"); $row = mysql_fetch_assoc($sql_res); mysql_free_result($sql_res); return(explode("','", preg_replace("/.*\('(.*)'\)/", "\\1", $row["Type"]))); } -- http://www.php.net/manual/en/function.mysql-field-flags.php http://master.php.net/manage/user-notes.php?action=edit+26452 http://master.php.net/manage/user-notes.php?action=delete+26452 http://master.php.net/manage/user-notes.php?action=reject+26452

« previous php.notes (#38815) next »