From: Ilia Alshanetsky Date: Fri, 2 Feb 2007 00:00:33 +0000 (+0000) Subject: Fixed test mixup X-Git-Tag: php-5.2.1~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79dfb302b1b206bcac24f143561c6dbe969fcc9e;p=php Fixed test mixup --- diff --git a/ext/pdo/tests/bug_39656.phpt b/ext/pdo/tests/bug_39656.phpt index c0a5674389..e1a283ce09 100644 --- a/ext/pdo/tests/bug_39656.phpt +++ b/ext/pdo/tests/bug_39656.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: Bug #40285 (The prepare parser goes into an infinite loop on ': or ":) +PDO Common: Bug #39656 (Crash when calling fetch() on a PDO statment object after closeCursor()) --SKIPIF-- exec('CREATE TABLE test (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32), field4 INT)'); +@$db->exec("DROP TABLE testtable"); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); -$s = $db->prepare("INSERT INTO test VALUES( ':id', 'name', 'section', 22)" ); -$s->execute(); +$db->exec("CREATE TABLE testtable (id INTEGER NOT NULL PRIMARY KEY, usr VARCHAR( 256 ) NOT NULL)"); +$db->exec("INSERT INTO testtable (id, usr) VALUES (1, 'user')"); + +$stmt = $db->prepare("SELECT * FROM testtable WHERE id = ?"); +$stmt->bindValue(1, 1, PDO::PARAM_INT ); +$stmt->execute(); +$row = $stmt->fetch(); +var_dump( $row ); + +$stmt->execute(); +$stmt->closeCursor(); +$row = $stmt->fetch(); // this line will crash CLI +var_dump( $row ); echo "Done\n"; ?> --EXPECT-- +array(4) { + ["id"]=> + string(1) "1" + [0]=> + string(1) "1" + ["usr"]=> + string(4) "user" + [1]=> + string(4) "user" +} +bool(false) Done + diff --git a/ext/pdo/tests/bug_40285.phpt b/ext/pdo/tests/bug_40285.phpt new file mode 100644 index 0000000000..c0a5674389 --- /dev/null +++ b/ext/pdo/tests/bug_40285.phpt @@ -0,0 +1,27 @@ +--TEST-- +PDO Common: Bug #40285 (The prepare parser goes into an infinite loop on ': or ":) +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32), field4 INT)'); + +$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); +$s = $db->prepare("INSERT INTO test VALUES( ':id', 'name', 'section', 22)" ); +$s->execute(); + +echo "Done\n"; +?> +--EXPECT-- +Done