Changeset 777 for trunk/include
- Timestamp:
- Apr 30, 2005, 4:36:57 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r764 r777 35 35 //----------------------------------------------------------- generic functions 36 36 37 /** 38 * returns an array containing the possible values of an enum field 39 * 40 * @param string tablename 41 * @param string fieldname 42 */ 43 function get_enums($table, $field) 44 { 45 // retrieving the properties of the table. Each line represents a field : 46 // columns are 'Field', 'Type' 47 $result = pwg_query('desc '.$table); 48 while ($row = mysql_fetch_array($result)) 49 { 50 // we are only interested in the the field given in parameter for the 51 // function 52 if ($row['Field'] == $field) 53 { 54 // retrieving possible values of the enum field 55 // enum('blue','green','black') 56 $options = explode(',', substr($row['Type'], 5, -1)); 57 foreach ($options as $i => $option) 58 { 59 $options[$i] = str_replace("'", '',$option); 60 } 61 } 62 } 63 mysql_free_result($result); 64 return $options; 65 } 66 37 67 // get_boolean transforms a string to a boolean value. If the string is 38 68 // "false" (case insensitive), then the boolean value false is returned. In
Note: See TracChangeset
for help on using the changeset viewer.