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