1--TEST-- 2PostgreSQL non-blocking async prepared queries 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php 7include("skipif.inc"); 8if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist'); 9?> 10--FILE-- 11<?php 12 13include('config.inc'); 14include('nonblocking.inc'); 15 16$db = pg_connect($conn_str); 17 18$version = pg_version($db); 19if ($version['protocol'] < 3) { 20 echo "OK"; 21 exit(0); 22} 23 24$db_socket = pg_socket($db); 25stream_set_blocking($db_socket, false); 26 27$nb_send = pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;"); 28if ($nb_send === FALSE) { 29 echo "pg_send_prepare() error\n"; 30} elseif ($nb_send === 0) { 31 nb_flush($db, $db_socket); 32} 33 34nb_consume($db, $db_socket); 35 36if (!($result = pg_get_result($db))) { 37 echo "pg_get_result() error\n"; 38} 39pg_free_result($result); 40 41$nb_send = pg_send_execute($db, 'php_test', array(100)); 42if ($nb_send === FALSE) { 43 echo "pg_send_execute() error\n"; 44} elseif ($nb_send === 0) { 45 nb_flush($db, $db_socket); 46} 47 48nb_consume($db, $db_socket); 49 50if (!($result = pg_get_result($db))) { 51 echo "pg_get_result() error\n"; 52} 53 54if (!($rows = pg_num_rows($result))) { 55 echo "pg_num_rows() error\n"; 56} 57for ($i=0; $i < $rows; $i++) { 58 pg_fetch_array($result, $i, PGSQL_NUM); 59} 60for ($i=0; $i < $rows; $i++) { 61 pg_fetch_object($result); 62} 63for ($i=0; $i < $rows; $i++) { 64 pg_fetch_row($result, $i); 65} 66for ($i=0; $i < $rows; $i++) { 67 pg_fetch_result($result, $i, 0); 68} 69 70pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); 71pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); 72pg_field_name($result, 0); 73pg_field_num($result, $field_name); 74pg_field_size($result, 0); 75pg_field_type($result, 0); 76pg_field_prtlen($result, 0); 77pg_field_is_null($result, 0); 78 79$nb_send = pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"); 80if ($nb_send === FALSE) { 81 echo "pg_send_prepare() error\n"; 82} elseif ($nb_send === 0) { 83 nb_flush($db, $db_socket); 84} 85 86nb_consume($db, $db_socket); 87 88if (!($result = pg_get_result($db))) { 89 echo "pg_get_result() error\n"; 90} 91pg_free_result($result); 92 93$nb_send = pg_send_execute($db, "php_test2", array(9999, "A'BC")); 94if ($nb_send === FALSE) { 95 echo "pg_send_execute() error\n"; 96} elseif ($nb_send === 0) { 97 nb_flush($db, $db_socket); 98} 99 100nb_consume($db, $db_socket); 101 102if (!($result = pg_get_result($db))) { 103 echo "pg_get_result() error\n"; 104} 105 106pg_last_oid($result); 107pg_free_result($result); 108pg_close($db); 109 110echo "OK"; 111?> 112--EXPECT-- 113OK 114