File indexing completed on 2025-01-26 05:29:15
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Amf 0017 * @subpackage Parse 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * This class will convert mysql result resource to array suitable for passing 0025 * to the external entities. 0026 * 0027 * @package Zend_Amf 0028 * @subpackage Parse 0029 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0030 * @license http://framework.zend.com/license/new-bsd New BSD License 0031 */ 0032 class Zend_Amf_Parse_Resource_MysqlResult 0033 { 0034 /** 0035 * @var array List of Mysql types with PHP counterparts 0036 * 0037 * Key => Value is Mysql type (exact string) => PHP type 0038 */ 0039 static public $fieldTypes = array( 0040 "int" => "int", 0041 "timestamp" => "int", 0042 "year" => "int", 0043 "real" => "float", 0044 ); 0045 /** 0046 * Parse resource into array 0047 * 0048 * @param resource $resource 0049 * @return array 0050 */ 0051 public function parse($resource) { 0052 $result = array(); 0053 $fieldcnt = mysql_num_fields($resource); 0054 $fields_transform = array(); 0055 for($i=0;$i<$fieldcnt;$i++) { 0056 $type = mysql_field_type($resource, $i); 0057 if(isset(self::$fieldTypes[$type])) { 0058 $fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type]; 0059 } 0060 } 0061 0062 while($row = mysql_fetch_object($resource)) { 0063 foreach($fields_transform as $fieldname => $fieldtype) { 0064 settype($row->$fieldname, $fieldtype); 0065 } 0066 $result[] = $row; 0067 } 0068 return $result; 0069 } 0070 }