cvs: pear /DB/tests/driver 18get.phpt

From: Date: Sat, 01 May 2004 02:42:18 +0000
Subject: cvs: pear /DB/tests/driver 18get.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-19053@lists.php.net to get a copy of this message
danielc Fri Apr 30 22:42:18 2004 EDT Modified files: /pear/DB/tests/driver 18get.phpt Log: Add getCol() tests for no records and wrong column name. http://cvs.php.net/diff.php/pear/DB/tests/driver/18get.phpt?r1=1.4&r2=1.5&ty=u Index: pear/DB/tests/driver/18get.phpt diff -u pear/DB/tests/driver/18get.phpt:1.4 pear/DB/tests/driver/18get.phpt:1.5 --- pear/DB/tests/driver/18get.phpt:1.4 Thu Apr 29 17:40:28 2004 +++ pear/DB/tests/driver/18get.phpt Fri Apr 30 22:42:17 2004 @@ -10,7 +10,7 @@ * DB_Common::getListOf(), DB_Common::getOne(), DB_Common::getRow() * * @package DB - * @version $Id: 18get.phpt,v 1.4 2004/04/29 21:40:28 danielc Exp $ + * @version $Id: 18get.phpt,v 1.5 2004/05/01 02:42:17 danielc Exp $ * @category Database * @author Daniel Convissor <danielc@analysisandsolutions.com> * @internal @@ -23,7 +23,7 @@ --FILE-- <?php -// $Id: 18get.phpt,v 1.4 2004/04/29 21:40:28 danielc Exp $ +// $Id: 18get.phpt,v 1.5 2004/05/01 02:42:17 danielc Exp $ /** * Connect to the database and make the <kbd>phptest</kbd> table. @@ -124,6 +124,20 @@ $ret =& $dbh->getCol("SELECT * FROM phptest ORDER BY b"); print_r($ret); +print "testing getCol on query with no records:\n"; +$ret =& $dbh->getCol('SELECT * FROM phptest WHERE b > 200'); +print_r($ret); + +print "testing getCol with invalid column id:\n"; +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$ret =& $dbh->getCol('SELECT b FROM phptest ORDER BY b', 1); +if (DB::isError($ret)) { + echo $ret->getMessage() . "\n"; +} else { + print ">> Should have produced 'no such field' error\n"; +} +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe'); + print "testing getCol with 1 col:\n"; $ret =& $dbh->getCol("SELECT * FROM phptest ORDER BY b", 1); print_r($ret); @@ -321,6 +335,12 @@ [1] => 42 [2] => 2 ) +testing getCol on query with no records: +Array +( +) +testing getCol with invalid column id: +DB Error: no such field testing getCol with 1 col: Array (

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