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