xref: /PHP-8.4/ext/pdo/tests/bug_35671.phpt (revision f4a5db3e)
1--TEST--
2PDO Common: Bug #35671 (binding by name breakage)
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no 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$db = PDOTest::factory();
17
18$db->exec('CREATE TABLE test35671 (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32))');
19$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
20
21$insert = $db->prepare("insert into test35671 (field1, field2, field3) values (:value1, :value2, :value3)");
22
23$parm = array(
24    ":value1" => 15,
25    ":value2" => 20,
26    ":value3" => 25
27);
28
29$insert->execute($parm);
30$insert = null;
31
32var_dump($db->query("SELECT * from test35671")->fetchAll(PDO::FETCH_ASSOC));
33
34?>
35--CLEAN--
36<?php
37require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
38$db = PDOTest::factory();
39PDOTest::dropTableIfExists($db, "test35671");
40?>
41--EXPECT--
42array(1) {
43  [0]=>
44  array(3) {
45    ["field1"]=>
46    string(2) "15"
47    ["field2"]=>
48    string(2) "20"
49    ["field3"]=>
50    string(2) "25"
51  }
52}
53