04async_query.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --TEST--
  2. PostgreSQL async query
  3. --SKIPIF--
  4. <?php include("skipif.inc"); ?>
  5. --FILE--
  6. <?php
  7. include('config.inc');
  8. $db = pg_connect($conn_str);
  9. if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
  10. echo "pg_send_query() error\n";
  11. }
  12. while(pg_connection_busy($db)); // busy wait: intended
  13. if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
  14. echo "pg_connection_status() error\n";
  15. }
  16. if (!($result = pg_get_result($db)))
  17. {
  18. echo "pg_get_result() error\n";
  19. }
  20. if (!($rows = pg_num_rows($result))) {
  21. echo "pg_num_rows() error\n";
  22. }
  23. for ($i=0; $i < $rows; $i++)
  24. {
  25. pg_fetch_array($result, $i, PGSQL_NUM);
  26. }
  27. for ($i=0; $i < $rows; $i++)
  28. {
  29. pg_fetch_object($result);
  30. }
  31. for ($i=0; $i < $rows; $i++)
  32. {
  33. pg_fetch_row($result, $i);
  34. }
  35. for ($i=0; $i < $rows; $i++)
  36. {
  37. pg_fetch_result($result, $i, 0);
  38. }
  39. pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
  40. pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
  41. pg_field_name($result, 0);
  42. pg_field_num($result, $field_name);
  43. pg_field_size($result, 0);
  44. pg_field_type($result, 0);
  45. pg_field_prtlen($result, 0);
  46. pg_field_is_null($result, 0);
  47. if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
  48. {
  49. echo "pg_send_query() error\n";
  50. }
  51. pg_last_oid($result);
  52. pg_free_result($result);
  53. echo "OK";
  54. ?>
  55. --EXPECT--
  56. OK