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

From: Date: Wed, 08 Feb 2006 15:42:04 +0000
Subject: cvs: pear /MDB2 MDB2.php /MDB2/MDB2 Iterator.php /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php
querysim.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38051@lists.php.net to get a copy of this message
lsmith Wed Feb 8 15:42:04 2006 UTC Modified files: /pear/MDB2 MDB2.php /pear/MDB2/MDB2 Iterator.php /pear/MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php querysim.php Log: - handle null as ressource when disable_query option is enabled in result object

http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2.php?r1=1.161&r2=1.162&diff_format=u Index: pear/MDB2/MDB2.php diff -u pear/MDB2/MDB2.php:1.161 pear/MDB2/MDB2.php:1.162 --- pear/MDB2/MDB2.php:1.161 Mon Jan 16 14:43:36 2006 +++ pear/MDB2/MDB2.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.161 2006/01/16 14:43:36 lsmith Exp $ +// $Id: MDB2.php,v 1.162 2006/02/08 15:42:04 lsmith Exp $ // /** @@ -1346,10 +1346,10 @@ * @param string $message Message with information for the user. * @access public */ - function debug($message, $scope = '') + function debug($message, $scope = '', $is_manip = null) { if ($this->options['debug'] && $this->options['debug_handler']) { - call_user_func_array($this->options['debug_handler'], array(&$this, $scope, $message)); + call_user_func_array($this->options['debug_handler'], array(&$this, $scope, $message, $is_manip)); } } @@ -1890,7 +1890,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, '_doQuery: method not implemented'); } @@ -2304,7 +2304,7 @@ $offset = $this->offset; $limit = $this->limit; $this->offset = $this->limit = 0; - $this->debug($query, 'prepare'); + $this->debug($query, 'prepare', $is_manip); $positions = array(); $placeholder_type_guess = $placeholder_type = null; $question = '?'; @@ -2696,7 +2696,7 @@ var $db; var $result; var $rownum = -1; - var $types; + var $types = array(); var $values = array(); var $offset; var $offset_count = 0; @@ -3122,7 +3122,7 @@ */ function free() { - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -3411,7 +3411,7 @@ * if the error code was unknown * @access public */ -function MDB2_defaultDebugOutput(&$db, $scope, $message) +function MDB2_defaultDebugOutput(&$db, $scope, $message, $is_manip = null) { $db->debug_output.= $scope.'('.$db->db_index.'): '; $db->debug_output.= $message.$db->getOption('log_line_break'); http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Iterator.php?r1=1.18&r2=1.19&diff_format=u Index: pear/MDB2/MDB2/Iterator.php diff -u pear/MDB2/MDB2/Iterator.php:1.18 pear/MDB2/MDB2/Iterator.php:1.19 --- pear/MDB2/MDB2/Iterator.php:1.18 Tue Dec 27 15:28:43 2005 +++ pear/MDB2/MDB2/Iterator.php Wed Feb 8 15:42:04 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: Iterator.php,v 1.18 2005/12/27 15:28:43 lsmith Exp $ +// $Id: Iterator.php,v 1.19 2006/02/08 15:42:04 lsmith Exp $ /** * @package MDB2 @@ -148,7 +148,7 @@ if ($this->result) { return $this->result->free(); } - $this->result = null; + $this->result = false; $this->row = null; return false; } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/fbsql.php?r1=1.85&r2=1.86&diff_format=u Index: pear/MDB2/MDB2/Driver/fbsql.php diff -u pear/MDB2/MDB2/Driver/fbsql.php:1.85 pear/MDB2/MDB2/Driver/fbsql.php:1.86 --- pear/MDB2/MDB2/Driver/fbsql.php:1.85 Thu Jan 12 17:58:44 2006 +++ pear/MDB2/MDB2/Driver/fbsql.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.85 2006/01/12 17:58:44 lsmith Exp $ +// $Id: fbsql.php,v 1.86 2006/02/08 15:42:04 lsmith Exp $ // /** @@ -309,7 +309,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->options['disable_query']) { if ($is_manip) { return 0; @@ -519,7 +519,7 @@ $row = @fbsql_fetch_row($this->result); } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -597,9 +597,11 @@ { $cols = @fbsql_num_fields($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -618,9 +620,11 @@ */ function nextResult() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'nextResult: resultset has already been freed'); + } elseif (is_null($this->result)) { + return false; } return @fbsql_next_result($this->result); } @@ -638,12 +642,12 @@ { $free = @fbsql_free_result($this->result); if (!$free) { - if (is_null($this->result)) { + if (!$this->result) { return MDB2_OK; } return $this->db->raiseError(); } - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -663,9 +667,11 @@ function seek($rownum = 0) { if ($this->rownum != ($rownum - 1) && !@fbsql_data_seek($this->result, $rownum)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); + } elseif (is_null($this->result)) { + return MDB2_OK; } return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'seek: tried to seek to an invalid row number ('.$rownum.')'); @@ -705,9 +711,11 @@ { $rows = @fbsql_num_rows($this->result); if (is_null($rows)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } return $this->db->raiseError(); } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/ibase.php?r1=1.134&r2=1.135&diff_format=u Index: pear/MDB2/MDB2/Driver/ibase.php diff -u pear/MDB2/MDB2/Driver/ibase.php:1.134 pear/MDB2/MDB2/Driver/ibase.php:1.135 --- pear/MDB2/MDB2/Driver/ibase.php:1.134 Sun Jan 22 18:30:16 2006 +++ pear/MDB2/MDB2/Driver/ibase.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.134 2006/01/22 18:30:16 lsmith Exp $ +// $Id: ibase.php,v 1.135 2006/02/08 15:42:04 lsmith Exp $ /** * MDB2 FireBird/InterBase driver @@ -474,7 +474,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->getOption('disable_query')) { if ($is_manip) { return 0; @@ -599,7 +599,7 @@ $offset = $this->offset; $limit = $this->limit; $this->offset = $this->limit = 0; - $this->debug($query, 'prepare'); + $this->debug($query, 'prepare', $is_manip); $placeholder_type_guess = $placeholder_type = null; $question = '?'; $colon = ':'; @@ -841,7 +841,7 @@ $row = @ibase_fetch_row($this->result); } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -925,9 +925,11 @@ } $cols = @ibase_num_fields($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -948,13 +950,13 @@ if (is_resource($this->result)) { $free = @ibase_free_result($this->result); if (!$free) { - if (is_null($this->result)) { + if (!$this->result) { return MDB2_OK; } return $this->db->raiseError(); } } - $this->result = null; + $this->result = false; return MDB2_OK; } @@ -1028,12 +1030,12 @@ */ function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) { - if ($this->result === true) { + if ($this->result === true || is_null($this->result)) { //query successfully executed, but without results... $null = null; return $null; } - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -1095,7 +1097,7 @@ */ function seek($rownum = 0) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); } @@ -1114,9 +1116,11 @@ */ function valid() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'valid: resultset has already been freed'); + } elseif (is_null($this->result)) { + return true; } if ($this->_fillBuffer($this->rownum + 1)) { return true; @@ -1135,9 +1139,11 @@ */ function numRows() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'seek: resultset has already been freed'); + 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } $this->_fillBuffer(); return $this->buffer_rownum; http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/mssql.php?r1=1.99&r2=1.100&diff_format=u Index: pear/MDB2/MDB2/Driver/mssql.php diff -u pear/MDB2/MDB2/Driver/mssql.php:1.99 pear/MDB2/MDB2/Driver/mssql.php:1.100 --- pear/MDB2/MDB2/Driver/mssql.php:1.99 Thu Jan 12 17:58:44 2006 +++ pear/MDB2/MDB2/Driver/mssql.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Frank M. Kromann <frank@kromann.info> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.99 2006/01/12 17:58:44 lsmith Exp $ +// $Id: mssql.php,v 1.100 2006/02/08 15:42:04 lsmith Exp $ // // {{{ Class MDB2_Driver_mssql /** @@ -337,7 +337,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->getOption('disable_query')) { if ($is_manip) { return 0; @@ -578,7 +578,7 @@ $row = @mssql_fetch_row($this->result); } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -657,9 +657,11 @@ { $cols = @mssql_num_fields($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -678,9 +680,11 @@ */ function nextResult() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'nextResult: resultset has already been freed'); + } elseif (is_null($this->result)) { + return false; } return @mssql_next_result($this->result); } @@ -698,12 +702,12 @@ { $free = @mssql_free_result($this->result); if (!$free) { - if (is_null($this->result)) { + if (!$this->result) { return MDB2_OK; } return $this->db->raiseError(); } - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -723,9 +727,11 @@ function seek($rownum = 0) { if ($this->rownum != ($rownum - 1) && !@mssql_data_seek($this->result, $rownum)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); + } elseif (is_null($this->result)) { + return MDB2_OK; } return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'seek: tried to seek to an invalid row number ('.$rownum.')'); @@ -764,9 +770,11 @@ { $rows = @mssql_num_rows($this->result); if (is_null($rows)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } return $this->db->raiseError(); } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/mysql.php?r1=1.95&r2=1.96&diff_format=u Index: pear/MDB2/MDB2/Driver/mysql.php diff -u pear/MDB2/MDB2/Driver/mysql.php:1.95 pear/MDB2/MDB2/Driver/mysql.php:1.96 --- pear/MDB2/MDB2/Driver/mysql.php:1.95 Thu Jan 26 09:42:44 2006 +++ pear/MDB2/MDB2/Driver/mysql.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.95 2006/01/26 09:42:44 lsmith Exp $ +// $Id: mysql.php,v 1.96 2006/02/08 15:42:04 lsmith Exp $ // /** @@ -449,7 +449,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->options['disable_query']) { if ($is_manip) { return 0; @@ -685,7 +685,7 @@ $query = "REPLACE INTO $table ($query) VALUES ($values)"; $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', true); $result = $this->_doQuery($query, true, $connection); if (PEAR::isError($result)) { return $result; @@ -822,7 +822,7 @@ } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -900,9 +900,11 @@ { $cols = @mysql_num_fields($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -922,12 +924,12 @@ { $free = @mysql_free_result($this->result); if (!$free) { - if (is_null($this->result)) { + if (!$this->result) { return MDB2_OK; } return $this->db->raiseError(); } - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -947,9 +949,11 @@ function seek($rownum = 0) { if ($this->rownum != ($rownum - 1) && !@mysql_data_seek($this->result, $rownum)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); + } elseif (is_null($this->result)) { + return MDB2_OK; } return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'seek: tried to seek to an invalid row number ('.$rownum.')'); @@ -989,9 +993,11 @@ { $rows = @mysql_num_rows($this->result); if (is_null($rows)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } return $this->db->raiseError(); } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/mysqli.php?r1=1.73&r2=1.74&diff_format=u Index: pear/MDB2/MDB2/Driver/mysqli.php diff -u pear/MDB2/MDB2/Driver/mysqli.php:1.73 pear/MDB2/MDB2/Driver/mysqli.php:1.74 --- pear/MDB2/MDB2/Driver/mysqli.php:1.73 Thu Jan 26 09:42:44 2006 +++ pear/MDB2/MDB2/Driver/mysqli.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.73 2006/01/26 09:42:44 lsmith Exp $ +// $Id: mysqli.php,v 1.74 2006/02/08 15:42:04 lsmith Exp $ // /** @@ -446,7 +446,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->options['disable_query']) { if ($is_manip) { return 0; @@ -612,7 +612,7 @@ $limit = $this->limit; $this->offset = $this->limit = 0; $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); - $this->debug($query, 'prepare'); + $this->debug($query, 'prepare', $is_manip); $placeholder_type_guess = $placeholder_type = null; $question = '?'; $colon = ':'; @@ -797,7 +797,7 @@ $query = "REPLACE INTO $table ($query) VALUES ($values)"; $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', true); $result = $this->_doQuery($query, true, $connection); if (PEAR::isError($result)) { return $result; @@ -934,7 +934,7 @@ } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -1012,9 +1012,11 @@ { $cols = @mysqli_num_fields($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -1062,7 +1064,7 @@ function free() { @mysqli_free_result($this->result); - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -1082,9 +1084,11 @@ function seek($rownum = 0) { if ($this->rownum != ($rownum - 1) && !@mysqli_data_seek($this->result, $rownum)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); + } elseif (is_null($this->result)) { + return MDB2_OK; } return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'seek: tried to seek to an invalid row number ('.$rownum.')'); @@ -1124,11 +1128,13 @@ { $rows = @mysqli_num_rows($this->result); if (is_null($rows)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } - + return $this->db->raiseError(); } return $rows; } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/oci8.php?r1=1.117&r2=1.118&diff_format=u Index: pear/MDB2/MDB2/Driver/oci8.php diff -u pear/MDB2/MDB2/Driver/oci8.php:1.117 pear/MDB2/MDB2/Driver/oci8.php:1.118 --- pear/MDB2/MDB2/Driver/oci8.php:1.117 Sun Jan 22 18:30:16 2006 +++ pear/MDB2/MDB2/Driver/oci8.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.117 2006/01/22 18:30:16 lsmith Exp $ +// $Id: oci8.php,v 1.118 2006/02/08 15:42:04 lsmith Exp $ /** * MDB2 OCI8 driver @@ -489,7 +489,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->getOption('disable_query')) { if ($is_manip) { return 0; @@ -605,7 +605,7 @@ $offset = $this->offset; $limit = $this->limit; $this->offset = $this->limit = 0; - $this->debug($query, 'prepare'); + $this->debug($query, 'prepare', $is_manip); $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); $placeholder_type_guess = $placeholder_type = null; $question = '?'; @@ -813,7 +813,7 @@ @OCIFetchInto($this->result, $row, OCI_RETURN_NULLS); } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -888,9 +888,11 @@ { $cols = @OCINumCols($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -910,12 +912,12 @@ { $free = @OCIFreeCursor($this->result); if (!$free) { - if (is_null($this->result)) { + if (!$this->result) { return MDB2_OK; } return $this->db->raiseError(); } - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -976,10 +978,12 @@ */ function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; + } elseif (is_null($this->result)) { + return null; } if (!is_null($rownum)) { $seek = $this->seek($rownum); @@ -1036,7 +1040,7 @@ */ function seek($rownum = 0) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); } @@ -1055,9 +1059,11 @@ */ function valid() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'valid: resultset has already been freed'); + } elseif (is_null($this->result)) { + return true; } if ($this->_fillBuffer($this->rownum + 1)) { return true; @@ -1076,9 +1082,11 @@ */ function numRows() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'seek: resultset has already been freed'); + 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } $this->_fillBuffer(); return $this->buffer_rownum; http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/pgsql.php?r1=1.94&r2=1.95&diff_format=u Index: pear/MDB2/MDB2/Driver/pgsql.php diff -u pear/MDB2/MDB2/Driver/pgsql.php:1.94 pear/MDB2/MDB2/Driver/pgsql.php:1.95 --- pear/MDB2/MDB2/Driver/pgsql.php:1.94 Sun Jan 22 18:30:16 2006 +++ pear/MDB2/MDB2/Driver/pgsql.php Wed Feb 8 15:42:04 2006 @@ -43,7 +43,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.94 2006/01/22 18:30:16 lsmith Exp $ +// $Id: pgsql.php,v 1.95 2006/02/08 15:42:04 lsmith Exp $ /** * MDB2 PostGreSQL driver @@ -446,7 +446,7 @@ function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($this->options['disable_query']) { if ($is_manip) { return 0; @@ -590,7 +590,7 @@ $offset = $this->offset; $limit = $this->limit; $this->offset = $this->limit = 0; - $this->debug($query, 'prepare'); + $this->debug($query, 'prepare', $is_manip); if (!empty($types)) { $this->loadModule('Datatype', null, true); } @@ -782,7 +782,7 @@ $row = @pg_fetch_row($this->result); } if (!$row) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; @@ -860,9 +860,11 @@ { $cols = @pg_num_fields($this->result); if (is_null($cols)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } return $this->db->raiseError(); } @@ -882,12 +884,12 @@ { $free = @pg_free_result($this->result); if (!$free) { - if (is_null($this->result)) { + if (!$this->result) { return MDB2_OK; } return $this->db->raiseError(); } - $this->result = null; + $this->result = false; return MDB2_OK; } } @@ -906,9 +908,11 @@ function seek($rownum = 0) { if ($this->rownum != ($rownum - 1) && !@pg_result_seek($this->result, $rownum)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); + } elseif (is_null($this->result)) { + return MDB2_OK; } return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'seek: tried to seek to an invalid row number ('.$rownum.')'); @@ -948,9 +952,11 @@ { $rows = @pg_num_rows($this->result); if (is_null($rows)) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } return $this->db->raiseError(); } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/querysim.php?r1=1.51&r2=1.52&diff_format=u Index: pear/MDB2/MDB2/Driver/querysim.php diff -u pear/MDB2/MDB2/Driver/querysim.php:1.51 pear/MDB2/MDB2/Driver/querysim.php:1.52 --- pear/MDB2/MDB2/Driver/querysim.php:1.51 Sun Jan 22 18:30:16 2006 +++ pear/MDB2/MDB2/Driver/querysim.php Wed Feb 8 15:42:04 2006 @@ -61,7 +61,7 @@ // | please contact Alan Richmond. | // +----------------------------------------------------------------------+ // -// $Id: querysim.php,v 1.51 2006/01/22 18:30:16 lsmith Exp $ +// $Id: querysim.php,v 1.52 2006/02/08 15:42:04 lsmith Exp $ // /* @@ -340,7 +340,7 @@ $query = $this->_readFile(); } $this->last_query = $query; - $this->debug($query, 'query'); + $this->debug($query, 'query', $is_manip); if ($is_manip) { return $this->raiseError(MDB2_ERROR_UNSUPPORTED); } @@ -577,10 +577,12 @@ */ function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) { - if (is_null($this->result)) { + if ($this->result === false) { $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetchRow: resultset has already been freed'); return $err; + } elseif (is_null($this->result)) { + return null; } if (!is_null($rownum)) { $seek = $this->seek($rownum); @@ -648,9 +650,11 @@ */ function _getColumnNames() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'getColumnNames: resultset has already been freed'); + } elseif (is_null($this->result)) { + return array(); } $columns = array_flip($this->result[0]); if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { @@ -671,9 +675,11 @@ */ function numCols() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed'); + } elseif (is_null($this->result)) { + return count($this->types); } $cols = count($this->result[0]); return $cols; @@ -694,7 +700,7 @@ */ function seek($rownum = 0) { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); } @@ -731,9 +737,11 @@ */ function numRows() { - if (is_null($this->result)) { + if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numRows: resultset has already been freed'); + } elseif (is_null($this->result)) { + return 0; } $rows = count($this->result[1]); return $rows;
« previous php.pear.cvs (#38051) next »