Get enum values from MySQL - Mysql Views : 1434
Tagged in : Mysql
0 0
Send mail
Get enum values from MySQL:

If you want to display enum values from mysql then use the following query,

$query = "SHOW COLUMNS FROM table_name LIKE 'field'";


it will result,

sql.gif

then extract the enum values using,

$result = mysql_query($query,$link);
$row1 = mysql_fetch_array( $result , MYSQL_NUM );
$regex = "/'(.*?)'/";
preg_match_all( $regex , $row1[1], $enum_array );
$enum_fields = $enum_array[1];


Here $regex extracts the values whichever is in between single quotes enum('value1','value2','value3')
ie., it extracts only value1value2value3.



By Ramya, On - 2008-12-05



    Login to add Comments .