1--TEST-- 2PostgreSQL async query params 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php 7include("inc/skipif.inc"); 8?> 9--FILE-- 10<?php 11 12include('inc/config.inc'); 13$table_name = "table_25async_query_params"; 14 15$db = pg_connect($conn_str); 16pg_query($db, "CREATE TABLE {$table_name} (num int, str text, bin bytea)"); 17pg_query($db, "INSERT INTO {$table_name} (num) VALUES(1000)"); 18 19if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) { 20 echo "pg_send_query_params() error\n"; 21} 22while(pg_connection_busy($db)); // busy wait: intended 23if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { 24 echo "pg_connection_status() error\n"; 25} 26if (!($result = pg_get_result($db))) 27{ 28 echo "pg_get_result() error\n"; 29} 30if (!($rows = pg_num_rows($result))) { 31 echo "pg_num_rows() error\n"; 32} 33for ($i=0; $i < $rows; $i++) 34{ 35 pg_fetch_array($result, $i, PGSQL_NUM); 36} 37for ($i=0; $i < $rows; $i++) 38{ 39 pg_fetch_object($result); 40} 41for ($i=0; $i < $rows; $i++) 42{ 43 pg_fetch_row($result, $i); 44} 45for ($i=0; $i < $rows; $i++) 46{ 47 pg_fetch_result($result, $i, 0); 48} 49 50pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); 51pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); 52pg_field_name($result, 0); 53pg_field_num($result, "num"); 54pg_field_size($result, 0); 55pg_field_type($result, 0); 56pg_field_prtlen($result, null, 0); 57pg_field_is_null($result, null, 0); 58 59if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"))) 60{ 61 echo "pg_send_query_params() error\n"; 62} 63 64pg_last_oid($result); 65pg_free_result($result); 66pg_close($db); 67 68echo "OK"; 69?> 70--CLEAN-- 71<?php 72include('inc/config.inc'); 73$table_name = "table_25async_query_params"; 74 75$db = pg_connect($conn_str); 76pg_query($db, "DROP TABLE IF EXISTS {$table_name}"); 77?> 78--EXPECT-- 79OK 80