summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-02-02 00:00:33 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-02-02 00:00:33 +0000
commit79dfb302b1b206bcac24f143561c6dbe969fcc9e (patch)
tree6902d40fcbe23b6b1c8f0c0d50d11333281c4615 /ext
parent44297ddea87236c97ce39df4fc9079dd7041e408 (diff)
downloadphp-git-79dfb302b1b206bcac24f143561c6dbe969fcc9e.tar.gz
Fixed test mixup
Diffstat (limited to 'ext')
-rw-r--r--ext/pdo/tests/bug_39656.phpt33
-rw-r--r--ext/pdo/tests/bug_40285.phpt27
2 files changed, 55 insertions, 5 deletions
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--
<?php
if (!extension_loaded('pdo')) die('skip');
@@ -15,13 +15,36 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
-$db->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--
+<?php
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+
+$db->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