cvs: pear /DB/tests numrows.inc prepexe.inc /DB/tests/driver 06prepexec.phpt 16tableinfo.phpt 17query.phpt mktable.inc

From: Date: Sat, 17 Jan 2004 18:40:48 +0000
Subject: cvs: pear /DB/tests numrows.inc prepexe.inc /DB/tests/driver 06prepexec.phpt 16tableinfo.phpt 17query.phpt mktable.inc
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-15739@lists.php.net to get a copy of this message
danielc Sat Jan 17 13:40:48 2004 EDT Modified files: /pear/DB/tests numrows.inc prepexe.inc /pear/DB/tests/driver 06prepexec.phpt 16tableinfo.phpt 17query.phpt mktable.inc Log: Change column b of phptest to CHAR in preparation for new portability features. Index: pear/DB/tests/numrows.inc diff -u pear/DB/tests/numrows.inc:1.4 pear/DB/tests/numrows.inc:1.5 --- pear/DB/tests/numrows.inc:1.4 Fri Jan 16 01:13:30 2004 +++ pear/DB/tests/numrows.inc Sat Jan 17 13:40:47 2004 @@ -29,7 +29,7 @@ print "\n"; } for ($i = 0; $i < 5; $i++) { - $sth = $dbh->query("INSERT INTO phptest (a) VALUES($i)"); + $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"; Index: pear/DB/tests/prepexe.inc diff -u pear/DB/tests/prepexe.inc:1.12 pear/DB/tests/prepexe.inc:1.13 --- pear/DB/tests/prepexe.inc:1.12 Fri Jan 16 01:13:30 2004 +++ pear/DB/tests/prepexe.inc Sat Jan 17 13:40:47 2004 @@ -33,11 +33,11 @@ echo "\n------------2------------\n"; $dbh->query('DELETE FROM phptest'); -$sth = $dbh->prepare("INSERT INTO phptest (a,b,c) VALUES (?,?,&)"); +$sth = $dbh->prepare('INSERT INTO phptest (a, b, c, d) VALUES (?, ?, &, ?)'); $data = array( - 0 => array(72, 'set1', $tmpfile), - 1 => array(72, 'set2', $tmpfile), - 2 => array(72, 'set3', $tmpfile) + 0 => array(72, 'set1', $tmpfile, '1234-56-78'), + 1 => array(72, 'set2', $tmpfile, null), + 2 => array(72, 'set3', $tmpfile, null) ); $dbh->executeMultiple($sth, $data); print_results(); @@ -64,8 +64,8 @@ $sth1 = $dbh->prepare("SELECT * FROM phptest WHERE a = ? ORDER BY b"); print_4($sth1, 72); print_4($sth1, 71); -$sth2 = $dbh->prepare("SELECT * FROM phptest WHERE b = ? ORDER BY b"); -print_4($sth2, 'set1'); +$sth2 = $dbh->prepare("SELECT * FROM phptest WHERE d = ? ORDER BY b"); +print_4($sth2, '1234-56-78'); $sth3 = $dbh->prepare("SELECT * FROM phptest WHERE c = & ORDER BY b"); print_4($sth3, $tmpfile); Index: pear/DB/tests/driver/06prepexec.phpt diff -u pear/DB/tests/driver/06prepexec.phpt:1.10 pear/DB/tests/driver/06prepexec.phpt:1.11 --- pear/DB/tests/driver/06prepexec.phpt:1.10 Thu Jan 15 23:39:53 2004 +++ pear/DB/tests/driver/06prepexec.phpt Sat Jan 17 13:40:48 2004 @@ -26,7 +26,7 @@ results: |72 - set1 - opaque placeholder -test - | +test - 1234-56-78| |72 - set2 - opaque placeholder test - | @@ -41,7 +41,7 @@ ------------4------------ |72 - set1 - opaque placeholder -test - | +test - 1234-56-78| |72 - set2 - opaque placeholder test - | @@ -52,11 +52,11 @@ ~~ |72 - set1 - opaque placeholder -test - | +test - 1234-56-78| ~~ |72 - set1 - opaque placeholder -test - | +test - 1234-56-78| |72 - set2 - opaque placeholder test - | Index: pear/DB/tests/driver/16tableinfo.phpt diff -u pear/DB/tests/driver/16tableinfo.phpt:1.3 pear/DB/tests/driver/16tableinfo.phpt:1.4 --- pear/DB/tests/driver/16tableinfo.phpt:1.3 Fri Jan 16 01:13:31 2004 +++ pear/DB/tests/driver/16tableinfo.phpt Sat Jan 17 13:40:48 2004 @@ -35,7 +35,7 @@ * @see DB_common::tableInfo() * * @package DB - * @version $Id: 16tableinfo.phpt,v 1.3 2004/01/16 06:13:31 danielc Exp $ + * @version $Id: 16tableinfo.phpt,v 1.4 2004/01/17 18:40:48 danielc Exp $ * @category Database * @author Daniel Convissor <danielc@analysisandsolutions.com> * @internal @@ -52,7 +52,7 @@ --FILE-- <?php -// $Id: 16tableinfo.phpt,v 1.3 2004/01/16 06:13:31 danielc Exp $ +// $Id: 16tableinfo.phpt,v 1.4 2004/01/17 18:40:48 danielc Exp $ /** * Connect to the database and make the phptest table. @@ -376,16 +376,6 @@ } -/* -The table generated by mktable.inc has the following format... - -CREATE TABLE phptest ( - a INTEGER NULL, - b VARCHAR(40) NULL, - c VARCHAR(255) NULL, - d VARCHAR(20) NULL -); -*/ $dbh->query('DELETE FROM phptest'); $dbh->query("INSERT INTO phptest VALUES (1, 'one', 'One', '2001-02-16')"); $dbh->query("INSERT INTO phptest VALUES (2, 'two', 'Two', '2001-02-15')"); Index: pear/DB/tests/driver/17query.phpt diff -u pear/DB/tests/driver/17query.phpt:1.4 pear/DB/tests/driver/17query.phpt:1.5 --- pear/DB/tests/driver/17query.phpt:1.4 Fri Jan 16 01:13:31 2004 +++ pear/DB/tests/driver/17query.phpt Sat Jan 17 13:40:48 2004 @@ -9,7 +9,7 @@ * @see DB_common::query() * * @package DB - * @version $Id: 17query.phpt,v 1.4 2004/01/16 06:13:31 danielc Exp $ + * @version $Id: 17query.phpt,v 1.5 2004/01/17 18:40:48 danielc Exp $ * @category Database * @author Daniel Convissor <danielc@analysisandsolutions.com> * @internal @@ -22,7 +22,7 @@ --FILE-- <?php -// $Id: 17query.phpt,v 1.4 2004/01/16 06:13:31 danielc Exp $ +// $Id: 17query.phpt,v 1.5 2004/01/17 18:40:48 danielc Exp $ /** * Connect to the database and make the phptest table. @@ -58,10 +58,10 @@ $res =& $dbh->query('DELETE FROM phptest WHERE a = 17'); print 'delete: ' . ($res == DB_OK ? 'okay' : 'error') . "\n"; -$res =& $dbh->query("INSERT INTO phptest (a, b) VALUES (17, 'one')"); +$res =& $dbh->query("INSERT INTO phptest (a, b, c) VALUES (17, 'one', 'One')"); print 'insert: ' . ($res == DB_OK ? 'okay' : 'error') . "\n"; -$res =& $dbh->query('INSERT INTO phptest (a, b) VALUES (?, ?)', array(17, 'two')); +$res =& $dbh->query('INSERT INTO phptest (a, b, c) VALUES (?, ?, ?)', array(17, 'two', 'Two')); print 'insert: ' . ($res == DB_OK ? 'okay' : 'error') . "\n"; @@ -69,7 +69,7 @@ $row = $res->fetchRow(); print "a = {$row['a']}, b = {$row['b']}\n"; -$res =& $dbh->query('SELECT a, b FROM phptest WHERE b = ?', array('two')); +$res =& $dbh->query('SELECT a, b FROM phptest WHERE c = ?', array('Two')); $row = $res->fetchRow(); print "a = {$row['a']}, b = {$row['b']}\n"; Index: pear/DB/tests/driver/mktable.inc diff -u pear/DB/tests/driver/mktable.inc:1.7 pear/DB/tests/driver/mktable.inc:1.8 --- pear/DB/tests/driver/mktable.inc:1.7 Tue Jan 13 00:03:05 2004 +++ pear/DB/tests/driver/mktable.inc Sat Jan 17 13:40:48 2004 @@ -1,4 +1,41 @@ <?php + +/** + * Creates the <kbd>phptest</kbd> table. + * + * Tries to drop the table first, in case it already exists. + * + * <pre> + * CREATE TABLE phptest ( + * a INTEGER NULL, + * b CHAR(40) DEFAULT 'def' NOT NULL, + * c VARCHAR(255) NULL, + * d VARCHAR(20) NULL) + * </pre> + * + * Need <kbd>NOT NULL</kbd> on <kbd>b</kbd> to test + * <kbd>DB_PORTABILITY_RTRIM</kbd>. MS SQL and Sybase trim output from + * <kbd>VARCHAR</kbd>, but not on <kbd>CHAR</kbd>. + * + * Need <kbd>DEFAULT</kbd> value on <kbd>b</kbd> because Oracle considers + * an empty string to be <kbd>NULL</kbd>. + * + * In Oracle, when using placeholders in <kbd>WHERE</kbd> clauses on + * <kbd>CHAR</kbd> columns, the column must have <kbd>RTRIM()</kbd> run on + * the column: + * <samp> + * SELECT * FROM phptest WHERE RTRIM(b) = ? + * </samp> + * + * @package DB + * @version $Id: mktable.inc,v 1.8 2004/01/17 18:40:48 danielc Exp $ + * @category Database + * @internal + */ + +/** + * Establishes the DB object and connects to the database. + */ require_once './connect.inc'; $dbh->setErrorHandling(PEAR_ERROR_RETURN); @@ -7,7 +44,14 @@ //$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'debug_die'); -$test_mktable_query = "CREATE TABLE phptest (a INTEGER NULL, b VARCHAR(40) NULL, c VARCHAR(255) NULL, d VARCHAR(20) NULL)"; +$test_mktable_query = " + CREATE TABLE phptest ( + a INTEGER NULL, + b CHAR(40) DEFAULT 'def' NOT NULL, + c VARCHAR(255) NULL, + d VARCHAR(20) NULL) +"; + $dbh->query($test_mktable_query); $dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')");

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