25async_query_params.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. PostgreSQL async query params
  3. --SKIPIF--
  4. <?php
  5. include("skipif.inc");
  6. if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
  7. ?>
  8. --FILE--
  9. <?php
  10. include('config.inc');
  11. $db = pg_connect($conn_str);
  12. $version = pg_version($db);
  13. if ($version['protocol'] >= 3) {
  14. if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) {
  15. echo "pg_send_query_params() error\n";
  16. }
  17. while(pg_connection_busy($db)); // busy wait: intended
  18. if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
  19. echo "pg_connection_status() error\n";
  20. }
  21. if (!($result = pg_get_result($db)))
  22. {
  23. echo "pg_get_result() error\n";
  24. }
  25. if (!($rows = pg_num_rows($result))) {
  26. echo "pg_num_rows() error\n";
  27. }
  28. for ($i=0; $i < $rows; $i++)
  29. {
  30. pg_fetch_array($result, $i, PGSQL_NUM);
  31. }
  32. for ($i=0; $i < $rows; $i++)
  33. {
  34. pg_fetch_object($result);
  35. }
  36. for ($i=0; $i < $rows; $i++)
  37. {
  38. pg_fetch_row($result, $i);
  39. }
  40. for ($i=0; $i < $rows; $i++)
  41. {
  42. pg_fetch_result($result, $i, 0);
  43. }
  44. pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
  45. pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
  46. pg_field_name($result, 0);
  47. pg_field_num($result, $field_name);
  48. pg_field_size($result, 0);
  49. pg_field_type($result, 0);
  50. pg_field_prtlen($result, 0);
  51. pg_field_is_null($result, 0);
  52. if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")))
  53. {
  54. echo "pg_send_query_params() error\n";
  55. }
  56. pg_last_oid($result);
  57. pg_free_result($result);
  58. }
  59. pg_close($db);
  60. echo "OK";
  61. ?>
  62. --EXPECT--
  63. OK