bug43925.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. --TEST--
  2. Bug #43925 (Incorrect argument counter in prepared statements with pgsql)
  3. --EXTENSIONS--
  4. pdo
  5. pdo_pgsql
  6. --SKIPIF--
  7. <?php
  8. require __DIR__ . '/config.inc';
  9. require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
  10. PDOTest::skip();
  11. ?>
  12. --FILE--
  13. <?php
  14. require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
  15. $dbh = PDOTest::test_factory(__DIR__ . '/common.phpt');
  16. @$dbh->query('DROP TABLE nodes');
  17. $dbh->query('
  18. CREATE 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. $dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (1, 1, 1, 6);');
  26. $dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (2, 1, 2, 3);');
  27. $dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (3, 1, 4, 5);');
  28. $stmt = $dbh->prepare('
  29. SELECT *
  30. FROM nodes
  31. WHERE (:rootId > 0 OR lft > :left OR rgt > :left)
  32. AND (root = :rootId OR root = :left)
  33. AND (1 > :left OR 1 < :left OR 1 = :left)
  34. AND (:x > 0 OR :x < 10 OR :x > 100)
  35. OR :y = 1 OR :left = 1
  36. ');
  37. $stmt->bindValue('left', 1, PDO::PARAM_INT);
  38. $stmt->bindValue('rootId', 3, PDO::PARAM_INT);
  39. $stmt->bindValue('x', 5, PDO::PARAM_INT);
  40. $stmt->bindValue('y', 50, PDO::PARAM_INT);
  41. $stmt->execute();
  42. foreach ($stmt->fetchAll() as $row) {
  43. print implode(' - ', $row);
  44. print "\n";
  45. }
  46. $dbh->query('DROP TABLE nodes');
  47. ?>
  48. --EXPECT--
  49. 1 - 1 - 1 - 1 - 1 - 1 - 6 - 6
  50. 2 - 2 - 1 - 1 - 2 - 2 - 3 - 3
  51. 3 - 3 - 1 - 1 - 4 - 4 - 5 - 5