pg_update_001.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. PostgreSQL pg_update() - 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 foo (id INT, id2 INT)');
  11. pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
  12. pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
  13. pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
  14. pg_update($conn, 'foo', array('id' => 10), array('id' => 1));
  15. var_dump(pg_update($conn, 'foo', array('id' => 10), array('id' => 1), PGSQL_DML_STRING));
  16. pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2));
  17. var_dump(pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2), PGSQL_DML_STRING));
  18. $rs = pg_query('SELECT * FROM foo UNION SELECT * FROM phptests.foo');
  19. while ($row = pg_fetch_assoc($rs)) {
  20. var_dump($row);
  21. }
  22. pg_query('DROP TABLE foo');
  23. pg_query('DROP TABLE phptests.foo');
  24. pg_query('DROP SCHEMA phptests');
  25. ?>
  26. --EXPECT--
  27. string(38) "UPDATE "foo" SET "id"=10 WHERE "id"=1;"
  28. string(51) "UPDATE "phptests"."foo" SET "id"=100 WHERE "id2"=2;"
  29. array(2) {
  30. ["id"]=>
  31. string(2) "10"
  32. ["id2"]=>
  33. string(1) "1"
  34. }
  35. array(2) {
  36. ["id"]=>
  37. string(3) "100"
  38. ["id2"]=>
  39. string(1) "2"
  40. }