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