xref: /PHP-5.4/ext/pdo_pgsql/tests/bug43925.phpt (revision 981a23ff)
1--TEST--
2Bug #43925 (Incorrect argument counter in prepared statements with pgsql)
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
12require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13$dbh = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
14
15@$dbh->query('DROP TABLE nodes');
16
17$dbh->query('
18CREATE TABLE nodes
19(
20   id   integer NOT NULL PRIMARY KEY
21 , root integer NOT NULL
22 , lft  integer NOT NULL
23 , rgt  integer NOT NULL
24);');
25
26$dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (1, 1, 1, 6);');
27$dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (2, 1, 2, 3);');
28$dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (3, 1, 4, 5);');
29
30
31$stmt = $dbh->prepare('
32	SELECT *
33	FROM nodes
34	WHERE (:rootId > 0 OR lft > :left OR rgt > :left)
35		AND (root = :rootId OR root  = :left)
36		AND (1 > :left OR 1 < :left OR 1 = :left)
37		AND (:x > 0 OR :x < 10 OR :x > 100)
38		OR :y = 1 OR :left = 1
39');
40
41$stmt->bindValue('left',   1, PDO::PARAM_INT);
42$stmt->bindValue('rootId', 3, PDO::PARAM_INT);
43$stmt->bindValue('x', 5, PDO::PARAM_INT);
44$stmt->bindValue('y', 50, PDO::PARAM_INT);
45
46$stmt->execute();
47
48foreach ($stmt->fetchAll() as $row) {
49	print implode(' - ', $row);
50	print "\n";
51}
52
53$dbh->query('DROP TABLE nodes');
54
55?>
56--EXPECTF--
571 - 1 - 1 - 1 - 1 - 1 - 6 - 6
582 - 2 - 1 - 1 - 2 - 2 - 3 - 3
593 - 3 - 1 - 1 - 4 - 4 - 5 - 5
60