Created
April 28, 2015 10:56
-
-
Save mrroot5/9d19ab2851c44bdb28a0 to your computer and use it in GitHub Desktop.
Obtener los valores de un enum.
From http://stackoverflow.com/questions/2350052/how-can-i-get-enum-possible-values-in-a-mysql-database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment