Find all enum values in MySql using php

 

  1. function get_enum_values($table, $field)
  2. {
  3. $sql = "SHOW COLUMNS FROM $table WHERE Field = '$field'";
  4. $type = $row['Type'];
  5. preg_match("/^enum\(\'(.*)\'\)$/", $type, $matches);
  6. $enum = explode("','", $matches[1]);
  7. return $enum;
  8. }

Leave a Reply