23sync_query_params.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. PostgreSQL sync query params
  3. --SKIPIF--
  4. <?php
  5. include("skipif.inc");
  6. if (!function_exists('pg_query_params')) die('skip function pg_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. $result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
  15. if (!($rows = pg_num_rows($result)))
  16. {
  17. echo "pg_num_row() error\n";
  18. }
  19. for ($i=0; $i < $rows; $i++)
  20. {
  21. pg_fetch_array($result, $i, PGSQL_NUM);
  22. }
  23. for ($i=0; $i < $rows; $i++)
  24. {
  25. pg_fetch_object($result);
  26. }
  27. for ($i=0; $i < $rows; $i++)
  28. {
  29. pg_fetch_row($result, $i);
  30. }
  31. for ($i=0; $i < $rows; $i++)
  32. {
  33. pg_fetch_result($result, $i, 0);
  34. }
  35. pg_result_error($result);
  36. pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
  37. pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
  38. pg_field_name($result, 0);
  39. pg_field_num($result, $field_name);
  40. pg_field_size($result, 0);
  41. pg_field_type($result, 0);
  42. pg_field_prtlen($result, 0);
  43. pg_field_is_null($result, 0);
  44. $result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
  45. pg_last_oid($result);
  46. pg_free_result($result);
  47. }
  48. pg_close($db);
  49. echo "OK";
  50. ?>
  51. --EXPECT--
  52. OK