Changeset 4367 for trunk/include/functions.inc.php
- Timestamp:
- Nov 25, 2009, 8:02:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r4325 r4367 33 33 34 34 //----------------------------------------------------------- generic functions 35 36 /**37 * returns an array containing the possible values of an enum field38 *39 * @param string tablename40 * @param string fieldname41 */42 function get_enums($table, $field)43 {44 // retrieving the properties of the table. Each line represents a field :45 // columns are 'Field', 'Type'46 $result = pwg_query('desc '.$table);47 while ($row = pwg_db_fetch_assoc($result))48 {49 // we are only interested in the the field given in parameter for the50 // function51 if ($row['Field'] == $field)52 {53 // retrieving possible values of the enum field54 // enum('blue','green','black')55 $options = explode(',', substr($row['Type'], 5, -1));56 foreach ($options as $i => $option)57 {58 $options[$i] = str_replace("'", '',$option);59 }60 }61 }62 pwg_db_free_result($result);63 return $options;64 }65 66 // get_boolean transforms a string to a boolean value. If the string is67 // "false" (case insensitive), then the boolean value false is returned. In68 // any other case, true is returned.69 function get_boolean( $string )70 {71 $boolean = true;72 if ( 'false' == strtolower($string) )73 {74 $boolean = false;75 }76 return $boolean;77 }78 79 /**80 * returns boolean string 'true' or 'false' if the given var is boolean81 *82 * @param mixed $var83 * @return mixed84 */85 function boolean_to_string($var)86 {87 if (is_bool($var))88 {89 return $var ? 'true' : 'false';90 }91 else92 {93 return $var;94 }95 }96 35 97 36 // The function get_moment returns a float value coresponding to the number … … 541 480 VALUES 542 481 ( 543 CUR DATE(),544 CUR TIME(),482 CURRENT_DATE, 483 CURRENT_TIME, 545 484 '.$user['id'].', 546 485 \''.$_SERVER['REMOTE_ADDR'].'\', … … 1498 1437 { 1499 1438 // Use MySql date in order to standardize all recent "actions/queries" 1500 list($cache['get_icon']['sql_recent_date']) = 1501 pwg_db_fetch_row(pwg_query('select SUBDATE( 1502 CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)')); 1439 $cache['get_icon']['sql_recent_date'] = pwg_db_get_recent_period($user['recent_period']); 1503 1440 } 1504 1441
Note: See TracChangeset
for help on using the changeset viewer.