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