25async_query_params.phpt 1.8 KB

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