23sync_query_params.phpt 1.5 KB

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