cvs: pear /DB package.xml /DB/DB oci8.php /DB/tests numrows.inc /DB/tests/driver 09numrows.phpt

From: Date: Fri, 12 Mar 2004 01:15:59 +0000
Subject: cvs: pear /DB package.xml /DB/DB oci8.php /DB/tests numrows.inc /DB/tests/driver 09numrows.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-17319@lists.php.net to get a copy of this message
danielc Thu Mar 11 20:15:59 2004 EDT Modified files: /pear/DB package.xml /pear/DB/DB oci8.php /pear/DB/tests numrows.inc /pear/DB/tests/driver 09numrows.phpt Log: Save $data passed to execute() so numRows() will work if called against executed statements. Bug 930. http://cvs.php.net/diff.php/pear/DB/package.xml?r1=1.85&r2=1.86&ty=u Index: pear/DB/package.xml diff -u pear/DB/package.xml:1.85 pear/DB/package.xml:1.86 --- pear/DB/package.xml:1.85 Wed Mar 10 22:48:47 2004 +++ pear/DB/package.xml Thu Mar 11 20:15:54 2004 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> - <!-- $Id: package.xml,v 1.85 2004/03/11 03:48:47 danielc Exp $ --> + <!-- $Id: package.xml,v 1.86 2004/03/12 01:15:54 danielc Exp $ --> <name>DB</name> <summary>Database Abstraction Layer</summary> <description> @@ -96,10 +96,14 @@ to mysqlRaiseError() so the feature can be turned on/off during runtime. (danielc) -- oci8 +- oci8: In tableInfo() only return num_fields key if $mode is set. (lsmith) +- oci8: +numRows() now works if called after execute(). +Bug 930. (danielc) + - sqlite: Now uses sqlite_escape_string() to escape strings in escapeSimple() and quoteSmart(). http://cvs.php.net/diff.php/pear/DB/DB/oci8.php?r1=1.61&r2=1.62&ty=u Index: pear/DB/DB/oci8.php diff -u pear/DB/DB/oci8.php:1.61 pear/DB/DB/oci8.php:1.62 --- pear/DB/DB/oci8.php:1.61 Tue Mar 2 10:50:23 2004 +++ pear/DB/DB/oci8.php Thu Mar 11 20:15:57 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: oci8.php,v 1.61 2004/03/02 15:50:23 lsmith Exp $ +// $Id: oci8.php,v 1.62 2004/03/12 01:15:57 danielc Exp $ // be aware... OCIError() only appears to return anything when given a @@ -34,7 +34,7 @@ * Definitely works with versions 8 and 9 of Oracle. * * @package DB - * @version $Id: oci8.php,v 1.61 2004/03/02 15:50:23 lsmith Exp $ + * @version $Id: oci8.php,v 1.62 2004/03/12 01:15:57 danielc Exp $ * @category Database * @author James L. Pine <jlp@valinux.com> */ @@ -49,6 +49,19 @@ var $autoCommit = 1; var $last_stmt = false; + /** + * stores the $data passed to execute() in the oci8 driver + * + * Gets reset to array() when simpleQuery() is run. + * + * Needed in case user wants to call numRows() after prepare/execute + * was used. + * + * @var array + * @access private + */ + var $_data = array(); + // }}} // {{{ constructor @@ -152,6 +165,7 @@ */ function simpleQuery($query) { + $this->_data = array(); $this->last_query = $query; $query = $this->modifyQuery($query); $result = @OCIParse($this->connection, $query); @@ -282,7 +296,14 @@ $countquery = 'SELECT COUNT(*) FROM ('.$this->last_query.')'; $save_query = $this->last_query; $save_stmt = $this->last_stmt; - $count =& $this->query($countquery); + + if (count($this->_data)) { + $smt = $this->prepare('SELECT COUNT(*) FROM ('.$this->last_query.')'); + $count = $this->execute($smt, $this->_data); + } else { + $count =& $this->query($countquery); + } + if (DB::isError($count) || DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED))) { @@ -431,6 +452,8 @@ $data = array($data); } + $this->_data = $data; + $types =& $this->prepare_types[$stmt]; if (count($types) != count($data)) { $tmp =& $this->raiseError(DB_ERROR_MISMATCH); http://cvs.php.net/diff.php/pear/DB/tests/numrows.inc?r1=1.6&r2=1.7&ty=u Index: pear/DB/tests/numrows.inc diff -u pear/DB/tests/numrows.inc:1.6 pear/DB/tests/numrows.inc:1.7 --- pear/DB/tests/numrows.inc:1.6 Fri Jan 23 12:53:05 2004 +++ pear/DB/tests/numrows.inc Thu Mar 11 20:15:58 2004 @@ -33,7 +33,7 @@ break; } if (!DB::isError($rows = $sth->numRows())) { - print "$rows\n"; + print "$rows from first\n"; } else { print "\n"; } @@ -41,22 +41,37 @@ $sth = $dbh->query("INSERT INTO phptest (a) VALUES ($i)"); $sth = $dbh->query("SELECT a FROM phptest"); if (!DB::isError($rows = $sth->numRows())) { - print "$rows\n"; + print "$rows from $i\n"; } else { print "\n"; } } +$sth = $dbh->query('SELECT a FROM phptest WHERE a > ?', 0); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows from > 0\n"; +} else { + print "\n"; +} + +$sth = $dbh->prepare('SELECT a FROM phptest WHERE a < ?'); +$res = $dbh->execute($sth, array(4)); +if (!DB::isError($rows = $res->numRows())) { + print "$rows from < 4\n"; +} else { + print "\n"; +} + $dbh->query("DELETE FROM phptest WHERE a < 4"); $sth = $dbh->query("SELECT a FROM phptest"); if (!DB::isError($rows = $sth->numRows())) { - print "$rows\n"; + print "$rows from 5 and 6 not deleted\n"; } else { print "\n"; } $sth = $dbh->query("SELECT a FROM phptest where a < 0"); if (!DB::isError($rows = $sth->numRows())) { - print "$rows\n"; + print "$rows from < 0\n"; } else { print "\n"; } http://cvs.php.net/diff.php/pear/DB/tests/driver/09numrows.phpt?r1=1.5&r2=1.6&ty=u Index: pear/DB/tests/driver/09numrows.phpt diff -u pear/DB/tests/driver/09numrows.phpt:1.5 pear/DB/tests/driver/09numrows.phpt:1.6 --- pear/DB/tests/driver/09numrows.phpt:1.5 Tue Jan 13 00:14:10 2004 +++ pear/DB/tests/driver/09numrows.phpt Thu Mar 11 20:15:59 2004 @@ -8,11 +8,13 @@ require_once '../numrows.inc'; ?> --EXPECT-- -1 -2 -3 -4 -5 -6 -2 -0 +1 from first +2 from 0 +3 from 1 +4 from 2 +5 from 3 +6 from 4 +5 from > 0 +4 from < 4 +2 from 5 and 6 not deleted +0 from < 0

« previous php.pear.cvs (#17319) next »