pg_select_001.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. PostgreSQL pg_select() - basic test using schema
  3. --SKIPIF--
  4. <?php include("skipif.inc"); ?>
  5. --FILE--
  6. <?php
  7. include('config.inc');
  8. $conn = pg_connect($conn_str);
  9. pg_query('CREATE SCHEMA phptests');
  10. pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
  11. pg_query('INSERT INTO phptests.foo VALUES (1,2)');
  12. pg_query('INSERT INTO phptests.foo VALUES (2,3)');
  13. pg_query('CREATE TABLE phptests.bar (id4 INT, id3 INT)');
  14. pg_query('INSERT INTO phptests.bar VALUES (4,5)');
  15. pg_query('INSERT INTO phptests.bar VALUES (6,7)');
  16. /* Inexistent table */
  17. var_dump(pg_select($conn, 'foo', array('id' => 1)));
  18. /* Existent column */
  19. var_dump(pg_select($conn, 'phptests.foo', array('id' => 1)));
  20. /* Testing with inexistent column */
  21. var_dump(pg_select($conn, 'phptests.bar', array('id' => 1)));
  22. /* Existent column */
  23. var_dump(pg_select($conn, 'phptests.bar', array('id4' => 4)));
  24. pg_query('DROP TABLE phptests.foo');
  25. pg_query('DROP TABLE phptests.bar');
  26. pg_query('DROP SCHEMA phptests');
  27. ?>
  28. --EXPECTF--
  29. Warning: pg_select(): Table 'foo' doesn't exists in %s on line %d
  30. bool(false)
  31. array(1) {
  32. [0]=>
  33. array(2) {
  34. ["id"]=>
  35. string(1) "1"
  36. ["id2"]=>
  37. string(1) "2"
  38. }
  39. }
  40. Notice: pg_select(): Invalid field name (id) in values in %s on line %d
  41. bool(false)
  42. array(1) {
  43. [0]=>
  44. array(2) {
  45. ["id4"]=>
  46. string(1) "4"
  47. ["id3"]=>
  48. string(1) "5"
  49. }
  50. }