我想用数据库中的枚举可能值自动填充我的下拉列表。这在MySQL中是可能的吗?
发布于 2016-05-03 21:41:13
所有人都使用一些奇怪而复杂的正则表达式模式x)
以下是我在没有preg_match的情况下的解决方案:
function getEnumTypes($table, $field) {
$query = $this->db->prepare("SHOW COLUMNS FROM $table WHERE Field = ?");
try {$query->execute(array($field));} catch (Exception $e) {error_log($e->getMessage());}
$types = $query->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 1)[$field];
return explode("','", trim($types, "enum()'"));
}https://stackoverflow.com/questions/2350052
复制相似问题