04async_query.phpt 1.3 KB

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