xref: /PHP-8.3/ext/pdo_pgsql/tests/bug69344.phpt (revision 39131219)
1--TEST--
2PDO PgSQL Bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps)
3--EXTENSIONS--
4pdo
5pdo_pgsql
6--SKIPIF--
7<?php
8require __DIR__ . '/config.inc';
9require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14
15require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
16$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
17$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
18$pdo->setAttribute (\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
19
20$test = function () use ($pdo) {
21    $arr = [
22        0 => "a",
23        2 => "b",
24    ];
25
26    $stmt = $pdo->prepare("SELECT (?)::text AS a, (?)::text AS b");
27
28    try {
29        $stmt->execute($arr);
30        var_dump($stmt->fetch());
31    } catch (\Exception $e) {
32        echo $e->getMessage()."\n";
33    }
34};
35
36$test();
37
38$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
39
40$test();
41
42?>
43--EXPECT--
44SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
45SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
46