1--TEST-- 2PostgreSQL async prepared queries 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_26async_query_prepared"; 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_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) { 20 echo "pg_send_prepare() 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} 30pg_free_result($result); 31 32if (!pg_send_execute($db, 'php_test', array(100))) { 33 echo "pg_send_execute() error\n"; 34} 35while(pg_connection_busy($db)); // busy wait: intended 36if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { 37 echo "pg_connection_status() error\n"; 38} 39if (!($result = pg_get_result($db))) 40{ 41 echo "pg_get_result() error\n"; 42} 43 44if (!($rows = pg_num_rows($result))) { 45 echo "pg_num_rows() error\n"; 46} 47for ($i=0; $i < $rows; $i++) 48{ 49 pg_fetch_array($result, $i, PGSQL_NUM); 50} 51for ($i=0; $i < $rows; $i++) 52{ 53 pg_fetch_object($result); 54} 55for ($i=0; $i < $rows; $i++) 56{ 57 pg_fetch_row($result, $i); 58} 59for ($i=0; $i < $rows; $i++) 60{ 61 pg_fetch_result($result, $i, 0); 62} 63 64pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); 65pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); 66pg_field_name($result, 0); 67pg_field_num($result, "num"); 68pg_field_size($result, 0); 69pg_field_type($result, 0); 70pg_field_prtlen($result, null, 0); 71pg_field_is_null($result, null, 0); 72 73if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);")) 74{ 75 echo "pg_send_prepare() error\n"; 76} 77while(pg_connection_busy($db)); // busy wait: intended 78if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { 79 echo "pg_connection_status() error\n"; 80} 81if (!($result = pg_get_result($db))) 82{ 83 echo "pg_get_result() error\n"; 84} 85pg_free_result($result); 86 87if (!pg_send_execute($db, "php_test2", array(9999, "A'BC"))) 88{ 89 echo "pg_send_execute() error\n"; 90} 91while(pg_connection_busy($db)); // busy wait: intended 92if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { 93 echo "pg_connection_status() error\n"; 94} 95if (!($result = pg_get_result($db))) 96{ 97 echo "pg_get_result() error\n"; 98} 99 100pg_last_oid($result); 101pg_free_result($result); 102pg_close($db); 103 104echo "OK"; 105?> 106--CLEAN-- 107<?php 108include('inc/config.inc'); 109$table_name = "table_26async_query_prepared"; 110 111$db = pg_connect($conn_str); 112pg_query($db, "DROP TABLE IF EXISTS {$table_name}"); 113?> 114--EXPECT-- 115OK 116