cvs: pear /MDB2 MDB2.php /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php sqlite.php
/MDB2/MDB2/Driver/Datatype Common.php fbsql.php ibase.php mssql.php oci8.php pgsql.php

From: Date: Sun, 20 Aug 2006 09:48:44 +0000
Subject: cvs: pear /MDB2 MDB2.php /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php sqlite.php
/MDB2/MDB2/Driver/Datatype Common.php fbsql.php ibase.php mssql.php oci8.php pgsql.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-41755@lists.php.net to get a copy of this message
lsmith Sun Aug 20 09:48:44 2006 UTC Modified files: /pear/MDB2 MDB2.php /pear/MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php sqlite.php /pear/MDB2/MDB2/Driver/Datatype Common.php fbsql.php ibase.php mssql.php oci8.php pgsql.php Log: - reverted the bulk of the recent rtrim changes because it was killing performance - if types have been defined, then rtrim is not done inside _fixResultArrayValues() but inside covertResult() instead (but only for type 'text')

http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2.php?r1=1.253&r2=1.254&diff_format=u Index: pear/MDB2/MDB2.php diff -u pear/MDB2/MDB2.php:1.253 pear/MDB2/MDB2.php:1.254 --- pear/MDB2/MDB2.php:1.253 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.253 2006/08/20 08:20:54 lsmith Exp $ +// $Id: MDB2.php,v 1.254 2006/08/20 09:48:43 lsmith Exp $ // /** @@ -1721,6 +1721,87 @@ return $this->connection; } + // }}} + // {{{ function _fixResultArrayValues(&$row, $mode) + + /** + * Do all necessary conversions on result arrays to fix DBMS quirks + * + * @param array the array to be fixed (passed by reference) + * @param array bit-wise addition of the required portability modes + * + * @return void + * + * @access protected + */ + function _fixResultArrayValues(&$row, $mode) + { + switch ($mode) { + case MDB2_PORTABILITY_EMPTY_TO_NULL: + foreach ($row as $key => $value) { + if ($value === '') { + $row[$key] = null; + } + } + break; + case MDB2_PORTABILITY_RTRIM: + foreach ($row as $key => $value) { + if (is_string($value)) { + $row[$key] = rtrim($value); + } + } + break; + case MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES: + $tmp_row = array(); + foreach ($row as $key => $value) { + $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; + } + $row = $tmp_row; + break; + case (MDB2_PORTABILITY_RTRIM + MDB2_PORTABILITY_EMPTY_TO_NULL): + foreach ($row as $key => $value) { + if ($value === '') { + $row[$key] = null; + } elseif (is_string($value)) { + $row[$key] = rtrim($value); + } + } + break; + case (MDB2_PORTABILITY_RTRIM + MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES): + $tmp_row = array(); + foreach ($row as $key => $value) { + if (is_string($value)) { + $value = rtrim($value); + } + $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; + } + $row = $tmp_row; + break; + case (MDB2_PORTABILITY_EMPTY_TO_NULL + MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES): + $tmp_row = array(); + foreach ($row as $key => $value) { + if ($value === '') { + $value = null; + } + $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; + } + $row = $tmp_row; + break; + case (MDB2_PORTABILITY_RTRIM + MDB2_PORTABILITY_EMPTY_TO_NULL + MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES): + $tmp_row = array(); + foreach ($row as $key => $value) { + if ($value === '') { + $value = null; + } elseif (is_string($value)) { + $value = rtrim($value); + } + $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; + } + $row = $tmp_row; + break; + } + } + // }}} // {{{ function &loadModule($module, $property = null, $phptype_specific = null) http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/fbsql.php?r1=1.122&r2=1.123&diff_format=u Index: pear/MDB2/MDB2/Driver/fbsql.php diff -u pear/MDB2/MDB2/Driver/fbsql.php:1.122 pear/MDB2/MDB2/Driver/fbsql.php:1.123 --- pear/MDB2/MDB2/Driver/fbsql.php:1.122 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2/Driver/fbsql.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.122 2006/08/20 08:20:54 lsmith Exp $ +// $Id: fbsql.php,v 1.123 2006/08/20 09:48:43 lsmith Exp $ // /** @@ -598,7 +598,12 @@ return $null; } $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; - $row = $this->db->datatype->convertResultRow($this->types, $row); + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, false); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/ibase.php?r1=1.186&r2=1.187&diff_format=u Index: pear/MDB2/MDB2/Driver/ibase.php diff -u pear/MDB2/MDB2/Driver/ibase.php:1.186 pear/MDB2/MDB2/Driver/ibase.php:1.187 --- pear/MDB2/MDB2/Driver/ibase.php:1.186 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2/Driver/ibase.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.186 2006/08/20 08:20:54 lsmith Exp $ +// $Id: ibase.php,v 1.187 2006/08/20 09:48:43 lsmith Exp $ /** * MDB2 FireBird/InterBase driver @@ -1049,9 +1049,21 @@ $null = null; return $null; } - $mode = $mode = ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) - + ($this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL); - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } @@ -1262,9 +1274,21 @@ } $row = $column_names; } - $mode = $mode = ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) - + ($this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL); - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mssql.php?r1=1.142&r2=1.143&diff_format=u Index: pear/MDB2/MDB2/Driver/mssql.php diff -u pear/MDB2/MDB2/Driver/mssql.php:1.142 pear/MDB2/MDB2/Driver/mssql.php:1.143 --- pear/MDB2/MDB2/Driver/mssql.php:1.142 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2/Driver/mssql.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Frank M. Kromann <frank@kromann.info> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.142 2006/08/20 08:20:54 lsmith Exp $ +// $Id: mssql.php,v 1.143 2006/08/20 09:48:43 lsmith Exp $ // // {{{ Class MDB2_Driver_mssql /** @@ -732,7 +732,12 @@ return $null; } $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; - $row = $this->db->datatype->convertResultRow($this->types, $row); + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, false); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mysql.php?r1=1.155&r2=1.156&diff_format=u Index: pear/MDB2/MDB2/Driver/mysql.php diff -u pear/MDB2/MDB2/Driver/mysql.php:1.155 pear/MDB2/MDB2/Driver/mysql.php:1.156 --- pear/MDB2/MDB2/Driver/mysql.php:1.155 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2/Driver/mysql.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.155 2006/08/20 08:20:54 lsmith Exp $ +// $Id: mysql.php,v 1.156 2006/08/20 09:48:43 lsmith Exp $ // /** @@ -1110,7 +1110,12 @@ return $null; } $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; - $row = $this->db->datatype->convertResultRow($this->types, $row); + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, false); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/mysqli.php?r1=1.131&r2=1.132&diff_format=u Index: pear/MDB2/MDB2/Driver/mysqli.php diff -u pear/MDB2/MDB2/Driver/mysqli.php:1.131 pear/MDB2/MDB2/Driver/mysqli.php:1.132 --- pear/MDB2/MDB2/Driver/mysqli.php:1.131 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2/Driver/mysqli.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.131 2006/08/20 08:20:54 lsmith Exp $ +// $Id: mysqli.php,v 1.132 2006/08/20 09:48:43 lsmith Exp $ // /** @@ -1152,7 +1152,12 @@ return $null; } $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; - $row = $this->db->datatype->convertResultRow($this->types, $row); + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, false); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/oci8.php?r1=1.173&r2=1.174&diff_format=u Index: pear/MDB2/MDB2/Driver/oci8.php diff -u pear/MDB2/MDB2/Driver/oci8.php:1.173 pear/MDB2/MDB2/Driver/oci8.php:1.174 --- pear/MDB2/MDB2/Driver/oci8.php:1.173 Sun Aug 20 08:20:54 2006 +++ pear/MDB2/MDB2/Driver/oci8.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.173 2006/08/20 08:20:54 lsmith Exp $ +// $Id: oci8.php,v 1.174 2006/08/20 09:48:43 lsmith Exp $ /** * MDB2 OCI8 driver @@ -990,8 +990,21 @@ if ($this->offset > 0) { array_pop($row); } - $mode = $this->db->options['portability'] & MDB2_PORTABILITY_RTRIM; - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = 0; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } @@ -1185,8 +1198,21 @@ } $row = $column_names; } - $mode = $this->db->options['portability'] & MDB2_PORTABILITY_RTRIM; - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = 0; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/pgsql.php?r1=1.153&r2=1.154&diff_format=u Index: pear/MDB2/MDB2/Driver/pgsql.php diff -u pear/MDB2/MDB2/Driver/pgsql.php:1.153 pear/MDB2/MDB2/Driver/pgsql.php:1.154 --- pear/MDB2/MDB2/Driver/pgsql.php:1.153 Sun Aug 20 08:20:55 2006 +++ pear/MDB2/MDB2/Driver/pgsql.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.153 2006/08/20 08:20:55 lsmith Exp $ +// $Id: pgsql.php,v 1.154 2006/08/20 09:48:43 lsmith Exp $ /** * MDB2 PostGreSQL driver @@ -999,9 +999,21 @@ $null = null; return $null; } - $mode = $mode = ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) - + ($this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL); - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/querysim.php?r1=1.74&r2=1.75&diff_format=u Index: pear/MDB2/MDB2/Driver/querysim.php diff -u pear/MDB2/MDB2/Driver/querysim.php:1.74 pear/MDB2/MDB2/Driver/querysim.php:1.75 --- pear/MDB2/MDB2/Driver/querysim.php:1.74 Sun Aug 20 08:20:55 2006 +++ pear/MDB2/MDB2/Driver/querysim.php Sun Aug 20 09:48:43 2006 @@ -61,7 +61,7 @@ // | please contact Alan Richmond. | // +----------------------------------------------------------------------+ // -// $Id: querysim.php,v 1.74 2006/08/20 08:20:55 lsmith Exp $ +// $Id: querysim.php,v 1.75 2006/08/20 09:48:43 lsmith Exp $ // /* @@ -649,9 +649,21 @@ } $row = $column_names; } - $mode = $mode = ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) - + ($this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL); - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/sqlite.php?r1=1.136&r2=1.137&diff_format=u Index: pear/MDB2/MDB2/Driver/sqlite.php diff -u pear/MDB2/MDB2/Driver/sqlite.php:1.136 pear/MDB2/MDB2/Driver/sqlite.php:1.137 --- pear/MDB2/MDB2/Driver/sqlite.php:1.136 Sun Aug 20 08:20:55 2006 +++ pear/MDB2/MDB2/Driver/sqlite.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.136 2006/08/20 08:20:55 lsmith Exp $ +// $Id: sqlite.php,v 1.137 2006/08/20 09:48:43 lsmith Exp $ // /** @@ -878,9 +878,21 @@ $null = null; return $null; } - $mode = $mode = ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) - + ($this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL); - $row = $this->db->datatype->convertResultRow($this->types, $row); + $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } if (!empty($this->values)) { $this->_assignBindColumns($row); } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/Common.php?r1=1.108&r2=1.109&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/Common.php diff -u pear/MDB2/MDB2/Driver/Datatype/Common.php:1.108 pear/MDB2/MDB2/Driver/Datatype/Common.php:1.109 --- pear/MDB2/MDB2/Driver/Datatype/Common.php:1.108 Sun Aug 20 08:35:51 2006 +++ pear/MDB2/MDB2/Driver/Datatype/Common.php Sun Aug 20 09:48:43 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.108 2006/08/20 08:35:51 lsmith Exp $ +// $Id: Common.php,v 1.109 2006/08/20 09:48:43 lsmith Exp $ require_once 'MDB2/LOB.php'; @@ -162,15 +162,15 @@ * general type conversion method * * @param mixed $value refernce to a value to be converted - * @param int $type constant that specifies which type to convert to + * @param string $type specifies which type to convert to * @return object a MDB2 error on failure * @access protected */ - function _baseConvertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function _baseConvertResult($value, $type, $rtrim = true) { switch ($type) { case 'text': - if ($mode & MDB2_PORTABILITY_RTRIM) { + if ($rtrim) { $value = rtrim($value); } return $value; @@ -205,20 +205,13 @@ return fopen('MDB2LOB://'.$lob_index.'@'.$this->db_index, 'r+'); } - if (is_null($type)) { - if ($mode & MDB2_PORTABILITY_RTRIM) { - $value = rtrim($value); - } - return $value; - } - $db =& $this->getDBInstance(); if (PEAR::isError($db)) { return $db; } return $db->raiseError(MDB2_ERROR_INVALID, null, null, - 'attempt to convert result value to an unknown type ' . $type, __FUNCTION__); + 'attempt to convert result value to an unknown type :' . $type, __FUNCTION__); } // }}} @@ -228,12 +221,12 @@ * convert a value to a RDBMS indepdenant MDB2 type * * @param mixed $value value to be converted - * @param int $type constant that specifies which type to convert to - * @param int $mode bit-wise addition of the required portability modes + * @param string $type specifies which type to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed converted value * @access public */ - function convertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function convertResult($value, $type, $rtrim = true) { if (is_null($value)) { return null; @@ -245,11 +238,11 @@ if (!empty($db->options['datatype_map'][$type])) { $type = $db->options['datatype_map'][$type]; if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type, 'value' => $value, 'mode' => $mode); + $parameter = array('type' => $type, 'value' => $value, 'rtrim' => $rtrim); return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); } } - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } // }}} @@ -258,30 +251,17 @@ /** * convert a result row * - * @param resource $result result identifier - * @param array $row array with data - * @param int $mode bit-wise addition of the required portability modes + * @param array $types + * @param array $row specifies the types to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed MDB2_OK on success, a MDB2 error on failure * @access public */ - function convertResultRow($types, $row, $mode = MDB2_PORTABILITY_ALL) + function convertResultRow($types, $row, $rtrim = true) { - if ($mode & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) { - $tmp_row = array(); - foreach ($row as $key => $value) { - $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; - } - $row = $tmp_row; - } - if (!is_array($types)) { - $types = array(); - } reset($types); $current_column = -1; foreach ($row as $key => $value) { - if (($mode & MDB2_PORTABILITY_EMPTY_TO_NULL) && $value === '') { - $row[$key] = null; - } ++$current_column; if (!isset($value)) { continue; @@ -294,9 +274,9 @@ $type = current($types); next($types); } else { - $type = null; + continue; } - $value = $this->convertResult($row[$key], $type, $mode); + $value = $this->convertResult($row[$key], $type, $rtrim); if (PEAR::isError($value)) { return $value; } http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/fbsql.php?r1=1.31&r2=1.32&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/fbsql.php diff -u pear/MDB2/MDB2/Driver/Datatype/fbsql.php:1.31 pear/MDB2/MDB2/Driver/Datatype/fbsql.php:1.32 --- pear/MDB2/MDB2/Driver/Datatype/fbsql.php:1.31 Sun Aug 20 08:35:51 2006 +++ pear/MDB2/MDB2/Driver/Datatype/fbsql.php Sun Aug 20 09:48:43 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.31 2006/08/20 08:35:51 lsmith Exp $ +// $Id: fbsql.php,v 1.32 2006/08/20 09:48:43 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -64,12 +64,12 @@ * convert a value to a RDBMS indepdenant MDB2 type * * @param mixed $value value to be converted - * @param int $type constant that specifies which type to convert to - * @param int $mode bit-wise addition of the required portability modes + * @param string $type specifies which type to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed converted value * @access public */ - function convertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function convertResult($value, $type, $rtrim = true) { if (is_null($value)) { return null; @@ -84,7 +84,7 @@ return $value; } } - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/ibase.php?r1=1.81&r2=1.82&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/ibase.php diff -u pear/MDB2/MDB2/Driver/Datatype/ibase.php:1.81 pear/MDB2/MDB2/Driver/Datatype/ibase.php:1.82 --- pear/MDB2/MDB2/Driver/Datatype/ibase.php:1.81 Sun Aug 20 08:35:51 2006 +++ pear/MDB2/MDB2/Driver/Datatype/ibase.php Sun Aug 20 09:48:43 2006 @@ -44,7 +44,7 @@ // | Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.81 2006/08/20 08:35:51 lsmith Exp $ +// $Id: ibase.php,v 1.82 2006/08/20 09:48:43 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -64,12 +64,12 @@ * convert a value to a RDBMS independent MDB2 type * * @param mixed $value value to be converted - * @param int $type constant that specifies which type to convert to - * @param int $mode bit-wise addition of the required portability modes + * @param string $type specifies which type to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed converted value or a MDB2 error on failure * @access public */ - function convertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function convertResult($value, $type, $rtrim = true) { if (is_null($value)) { return null; @@ -83,7 +83,7 @@ case 'timestamp': return substr($value, 0, strlen('YYYY-MM-DD HH:MM:SS')); } - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/mssql.php?r1=1.43&r2=1.44&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mssql.php diff -u pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.43 pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.44 --- pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.43 Sun Aug 20 08:35:51 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mssql.php Sun Aug 20 09:48:43 2006 @@ -44,7 +44,7 @@ // | Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.43 2006/08/20 08:35:51 lsmith Exp $ +// $Id: mssql.php,v 1.44 2006/08/20 09:48:43 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -64,12 +64,12 @@ * convert a value to a RDBMS indepdenant MDB2 type * * @param mixed $value value to be converted - * @param int $type constant that specifies which type to convert to - * @param int $mode bit-wise addition of the required portability modes + * @param string $type specifies which type to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed converted value * @access public */ - function convertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function convertResult($value, $type, $rtrim = true) { if (is_null($value)) { return null; @@ -88,7 +88,7 @@ } return $value; } - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } // }}} // {{{ getTypeDeclaration() http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/oci8.php?r1=1.64&r2=1.65&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/oci8.php diff -u pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.64 pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.65 --- pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.64 Sun Aug 20 08:35:51 2006 +++ pear/MDB2/MDB2/Driver/Datatype/oci8.php Sun Aug 20 09:48:43 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.64 2006/08/20 08:35:51 lsmith Exp $ +// $Id: oci8.php,v 1.65 2006/08/20 09:48:43 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -61,12 +61,12 @@ * convert a value to a RDBMS indepdenant MDB2 type * * @param mixed $value value to be converted - * @param int $type constant that specifies which type to convert to - * @param int $mode bit-wise addition of the required portability modes + * @param string $type specifies which type to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed converted value * @access public */ - function convertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function convertResult($value, $type, $rtrim = true) { if (is_null($value)) { return null; @@ -77,7 +77,7 @@ case 'time': return substr($value, strlen('YYYY-MM-DD '), strlen('HH:MI:SS')); } - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/pgsql.php?r1=1.73&r2=1.74&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/pgsql.php diff -u pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.73 pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.74 --- pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.73 Sun Aug 20 08:35:51 2006 +++ pear/MDB2/MDB2/Driver/Datatype/pgsql.php Sun Aug 20 09:48:44 2006 @@ -42,7 +42,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.73 2006/08/20 08:35:51 lsmith Exp $ +// $Id: pgsql.php,v 1.74 2006/08/20 09:48:44 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -61,12 +61,12 @@ * convert a value to a RDBMS independent MDB2 type * * @param mixed $value value to be converted - * @param int $type constant that specifies which type to convert to - * @param int $mode bit-wise addition of the required portability modes + * @param string $type specifies which type to convert to + * @param bool $rtrim if to rtrim text values or not * @return mixed converted value or a MDB2 error on failure * @access public */ - function convertResult($value, $type, $mode = MDB2_PORTABILITY_ALL) + function convertResult($value, $type, $rtrim = true) { if (is_null($value)) { return null; @@ -84,9 +84,9 @@ return substr($value, 0, strlen('YYYY-MM-DD HH:MM:SS')); case 'blob': $value = pg_unescape_bytea($value); - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } - return $this->_baseConvertResult($value, $type, $mode); + return $this->_baseConvertResult($value, $type, $rtrim); } // }}}
« previous php.pear.cvs (#41755) next »