xref: /PHP-8.4/ext/pdo/tests/bug_38394.phpt (revision f4a5db3e)
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 test38394 (a INT, b INT, c INT)");
20$s = $db->prepare("INSERT INTO test38394 (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 test38394")->fetchAll(PDO::FETCH_ASSOC));
29?>
30--CLEAN--
31<?php
32require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
33$db = PDOTest::factory();
34PDOTest::dropTableIfExists($db, "test38394");
35?>
36--EXPECT--
37array(2) {
38  [0]=>
39  array(3) {
40    ["a"]=>
41    string(1) "1"
42    ["b"]=>
43    string(1) "2"
44    ["c"]=>
45    string(1) "3"
46  }
47  [1]=>
48  array(3) {
49    ["a"]=>
50    string(1) "9"
51    ["b"]=>
52    string(2) "10"
53    ["c"]=>
54    string(2) "11"
55  }
56}
57