cvs: php4 /pear/DB mysql.php /pear/DB/tests sequences.inc /pear/DB/tests/mysql 005.phpt /pear/DB/tests/oci8 005.phpt /pear/DB/tests/pgsql 005.phpt

From: Date: Sat, 21 Jul 2001 23:50:06 +0000
Subject: cvs: php4 /pear/DB mysql.php /pear/DB/tests sequences.inc /pear/DB/tests/mysql 005.phpt /pear/DB/tests/oci8 005.phpt /pear/DB/tests/pgsql 005.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-306@lists.php.net to get a copy of this message
ssb Sat Jul 21 19:50:06 2001 EDT Modified files: /php4/pear/DB mysql.php /php4/pear/DB/tests sequences.inc /php4/pear/DB/tests/mysql 005.phpt /php4/pear/DB/tests/oci8 005.phpt /php4/pear/DB/tests/pgsql 005.phpt Log: (PEAR DB) handle error handlers properly in nextId() Index: php4/pear/DB/mysql.php diff -u php4/pear/DB/mysql.php:1.61 php4/pear/DB/mysql.php:1.62 --- php4/pear/DB/mysql.php:1.61 Sat Jul 14 16:02:53 2001 +++ php4/pear/DB/mysql.php Sat Jul 21 19:50:06 2001 @@ -373,7 +373,11 @@ $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); $repeat = 0; do { + // XXX HACK: temporarily force error mode to "return" + $tmp = $this->_default_error_mode; +// $this->_default_error_mode = PEAR_ERROR_RETURN; $result = $this->query("INSERT INTO ${sqn}_seq VALUES(NULL)"); +// $this->_default_error_mode = $tmp; if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { $repeat = 1; Index: php4/pear/DB/tests/sequences.inc diff -u php4/pear/DB/tests/sequences.inc:1.2 php4/pear/DB/tests/sequences.inc:1.3 --- php4/pear/DB/tests/sequences.inc:1.2 Thu Mar 22 20:15:06 2001 +++ php4/pear/DB/tests/sequences.inc Sat Jul 21 19:50:06 2001 @@ -1,9 +1,19 @@ -<?php +<?php // -*- PHP -*- + +function error_handler(&$obj) { + print "sequences.inc error_handler\n"; +} + $dbh->dropSequence("test"); + +// test that sequences are not created if "ondemand" is false $e = $dbh->nextId("test", false); if (DB::isError($e)) { print $e->getMessage() . "\n"; } + +// test that sequences are created if "ondemand" is true, and that +// two successive nextIds return adjacent values $a = $dbh->nextId("test"); $b = $dbh->nextId("test"); if (DB::isError($a)) { @@ -16,5 +26,29 @@ } else { print "b=$b\n"; } +print "b-a=".($b-$a)."\n"; + +// test that the user-specified error handler is really disabled +// during nextId, with per-object handler as well as global handler +$dbh->dropSequence("test"); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "error_handler"); +$c = $dbh->nextId("test"); +if (DB::isError($c)) { + print "c: ".$c->toString()."\n"; +} else { + print "c=$c\n"; +} +$dbh->dropSequence("test"); +$dbh->_default_error_mode = null; +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "error_handler"); +$d = $dbh->nextId("test"); +if (DB::isError($d)) { + print "d: ".$d->toString()."\n"; +} else { + print "d=$d\n"; +} + +// final clean-up $dbh->dropSequence("test"); + ?> Index: php4/pear/DB/tests/mysql/005.phpt diff -u php4/pear/DB/tests/mysql/005.phpt:1.3 php4/pear/DB/tests/mysql/005.phpt:1.4 --- php4/pear/DB/tests/mysql/005.phpt:1.3 Wed Dec 13 09:41:04 2000 +++ php4/pear/DB/tests/mysql/005.phpt Sat Jul 21 19:50:06 2001 @@ -11,3 +11,6 @@ DB Error: no such table a=1 b=2 +b-a=1 +c=1 +d=1 Index: php4/pear/DB/tests/oci8/005.phpt diff -u php4/pear/DB/tests/oci8/005.phpt:1.1 php4/pear/DB/tests/oci8/005.phpt:1.2 --- php4/pear/DB/tests/oci8/005.phpt:1.1 Sun Feb 18 19:49:07 2001 +++ php4/pear/DB/tests/oci8/005.phpt Sat Jul 21 19:50:06 2001 @@ -11,3 +11,6 @@ DB Error: no such table a=1 b=2 +b-a=1 +c=1 +d=1 Index: php4/pear/DB/tests/pgsql/005.phpt diff -u php4/pear/DB/tests/pgsql/005.phpt:1.3 php4/pear/DB/tests/pgsql/005.phpt:1.4 --- php4/pear/DB/tests/pgsql/005.phpt:1.3 Thu Dec 14 21:36:18 2000 +++ php4/pear/DB/tests/pgsql/005.phpt Sat Jul 21 19:50:06 2001 @@ -11,3 +11,6 @@ DB Error: no such table a=1 b=2 +b-a=1 +c=1 +d=1

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