Skip to content

Instantly share code, notes, and snippets.

@zandzpider
Created September 23, 2014 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zandzpider/659d39ee8acc8fcb7209 to your computer and use it in GitHub Desktop.
Save zandzpider/659d39ee8acc8fcb7209 to your computer and use it in GitHub Desktop.
<?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