pg_update_001.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. PostgreSQL pg_update() - basic test using schema
  3. --EXTENSIONS--
  4. pgsql
  5. --SKIPIF--
  6. <?php include("skipif.inc"); ?>
  7. --FILE--
  8. <?php
  9. include('config.inc');
  10. $conn = pg_connect($conn_str);
  11. pg_query($conn, 'CREATE SCHEMA phptests');
  12. pg_query($conn, 'CREATE TABLE foo (id INT, id2 INT)');
  13. pg_query($conn, 'CREATE TABLE phptests.foo (id INT, id2 INT)');
  14. pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
  15. pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
  16. pg_update($conn, 'foo', array('id' => 10), array('id' => 1));
  17. var_dump(pg_update($conn, 'foo', array('id' => 10), array('id' => 1), PGSQL_DML_STRING));
  18. pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2));
  19. var_dump(pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2), PGSQL_DML_STRING));
  20. $rs = pg_query($conn, 'SELECT * FROM foo UNION SELECT * FROM phptests.foo ORDER BY id');
  21. while ($row = pg_fetch_assoc($rs)) {
  22. var_dump($row);
  23. }
  24. pg_query($conn, 'DROP TABLE foo');
  25. pg_query($conn, 'DROP TABLE phptests.foo');
  26. pg_query($conn, 'DROP SCHEMA phptests');
  27. ?>
  28. --EXPECT--
  29. string(38) "UPDATE "foo" SET "id"=10 WHERE "id"=1;"
  30. string(51) "UPDATE "phptests"."foo" SET "id"=100 WHERE "id2"=2;"
  31. array(2) {
  32. ["id"]=>
  33. string(2) "10"
  34. ["id2"]=>
  35. string(1) "1"
  36. }
  37. array(2) {
  38. ["id"]=>
  39. string(3) "100"
  40. ["id2"]=>
  41. string(1) "2"
  42. }