xref: /PHP-8.0/ext/pdo/tests/bug_38394.phpt (revision a555cc0b)
1--TEST--
2PDO Common: Bug #38394 (Prepared statement error stops subsequent statements)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8if (!strncasecmp(getenv('PDOTEST_DSN'), 'sqlite2', strlen('sqlite2'))) die('skip not relevant for pdo_sqlite2 driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
16
17$db = PDOTest::factory();
18$db->exec("CREATE TABLE test (a INT, b INT, c INT)");
19$s = $db->prepare("INSERT INTO test (a,b,c) VALUES (:a,:b,:c)");
20
21$s->execute(array('a' => 1, 'b' => 2, 'c' => 3));
22
23@$s->execute(array('a' => 5, 'b' => 6, 'c' => 7, 'd' => 8));
24
25$s->execute(array('a' => 9, 'b' => 10, 'c' => 11));
26
27var_dump($db->query("SELECT * FROM test")->fetchAll(PDO::FETCH_ASSOC));
28?>
29--EXPECT--
30array(2) {
31  [0]=>
32  array(3) {
33    ["a"]=>
34    string(1) "1"
35    ["b"]=>
36    string(1) "2"
37    ["c"]=>
38    string(1) "3"
39  }
40  [1]=>
41  array(3) {
42    ["a"]=>
43    string(1) "9"
44    ["b"]=>
45    string(2) "10"
46    ["c"]=>
47    string(2) "11"
48  }
49}
50