diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Amf/Parse/Resource/MysqlResult.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Amf/Parse/Resource/MysqlResult.php Fri Mar 11 15:05:35 2011 +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; + } +}