bug64953.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --TEST--
  2. PDO PgSQL Bug #64953 (Postgres prepared statement positional parameter casting)
  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. echo "Test\n";
  15. require __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. echo "Taken from the bug report:\n";
  19. $st = $pdo->prepare('SELECT ?::char as i');
  20. $st->bindValue(1, '1');
  21. $st->execute();
  22. var_dump($st->fetch()); // return false
  23. $st = $pdo->prepare('SELECT (?)::char as i');
  24. $st->bindValue(1, '1');
  25. $st->execute();
  26. var_dump($st->fetch()); // return array(1) { ["i"]=> string(1) "1" }
  27. echo "Something more nasty:\n";
  28. $st = $pdo->prepare("SELECT :int::int as i");
  29. $st->execute(array(":int" => 123));
  30. var_dump($st->fetch());
  31. $st = $pdo->prepare("SELECT '''?'''::text as \":text\"");
  32. $st->execute();
  33. var_dump($st->fetch());
  34. ?>
  35. Done
  36. --EXPECT--
  37. Test
  38. Taken from the bug report:
  39. array(2) {
  40. ["i"]=>
  41. string(1) "1"
  42. [0]=>
  43. string(1) "1"
  44. }
  45. array(2) {
  46. ["i"]=>
  47. string(1) "1"
  48. [0]=>
  49. string(1) "1"
  50. }
  51. Something more nasty:
  52. array(2) {
  53. ["i"]=>
  54. string(3) "123"
  55. [0]=>
  56. string(3) "123"
  57. }
  58. array(2) {
  59. [":text"]=>
  60. string(3) "'?'"
  61. [0]=>
  62. string(3) "'?'"
  63. }
  64. Done