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