[SOLVED] How can I get enum possible values in a MySQL database?


I want to populate my dropdowns with enum possible values from a DB automatically. Is this possible in MySQL?


I have a codeigniter version for you. It also strips the quotes from the values.

function get_enum_values( $table, $field )
    $type = $this->db->query( "SHOW COLUMNS FROM {$table} WHERE Field = '{$field}'" )->row( 0 )->Type;
    preg_match("/^enum\(\'(.*)\'\)$/", $type, $matches);
    $enum = explode("','", $matches[1]);
    return $enum;

Answered By – Patrick Savalle

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *