Value is Mysql type (exact string) => PHP type */ static public $fieldTypes = array( "int" => "int", "timestamp" => "int", "year" => "int", "real" => "float", ); /** * Parse resource into array * * @param resource $resource * @return array */ public function parse($resource) { $result = array(); $fieldcnt = mysql_num_fields($resource); $fields_transform = array(); for($i=0;$i<$fieldcnt;$i++) { $type = mysql_field_type($resource, $i); if(isset(self::$fieldTypes[$type])) { $fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type]; } } while($row = mysql_fetch_assoc($resource)) { foreach($fields_transform as $fieldname => $fieldtype) { settype($row[$fieldname], $fieldtype); } $result[] = $row; } return $result; } }