Created
September 23, 2014 09:00
-
-
Save zandzpider/659d39ee8acc8fcb7209 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* | |
* @param string $table | |
* @param string $field | |
* @return object | |
*/ | |
public function enum_select($table, $field) | |
{ | |
$row = $this->db->query("SHOW COLUMNS FROM `$table` LIKE '$field'")->row(); | |
if(is_object($row)) | |
{ | |
$options = explode("','", preg_replace("/(enum|set)\('(.+?)'\)/","\\2", $row->Type)); | |
$options2 = array(); | |
foreach($options as $value) | |
{ | |
$options2[] = (object) array( | |
'value' => $value, | |
'display' => htmlentities($value), | |
); | |
} | |
return $options2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment