diff -r 000000000000 -r 4eba9c11703f web/Zend/Amf/Parse/Resource/MysqlResult.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Amf/Parse/Resource/MysqlResult.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,70 @@ + 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_object($resource)) { + foreach($fields_transform as $fieldname => $fieldtype) { + settype($row->$fieldname, $fieldtype); + } + $result[] = $row; + } + return $result; + } +}