1--TEST-- 2PostgreSQL sync prepared queries 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php 7include("inc/skipif.inc"); 8if (!function_exists('pg_prepare')) die('skip function pg_prepare() does not exist'); 9?> 10--FILE-- 11<?php 12 13include('inc/config.inc'); 14$table_name = "table_24sync_query_prepared"; 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$result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;"); 21pg_result_error($result); 22pg_free_result($result); 23$result = pg_execute($db, "php_test", array(100)); 24if (!($rows = pg_num_rows($result))) 25{ 26 echo "pg_num_row() error\n"; 27} 28for ($i=0; $i < $rows; $i++) 29{ 30 pg_fetch_array($result, $i, PGSQL_NUM); 31} 32for ($i=0; $i < $rows; $i++) 33{ 34 pg_fetch_object($result); 35} 36for ($i=0; $i < $rows; $i++) 37{ 38 pg_fetch_row($result, $i); 39} 40for ($i=0; $i < $rows; $i++) 41{ 42 pg_fetch_result($result, $i, 0); 43} 44 45pg_result_error($result); 46pg_num_rows(pg_execute($db, "php_test", array(100))); 47pg_num_fields(pg_execute($db, "php_test", array(100))); 48pg_field_name($result, 0); 49pg_field_num($result, "num"); 50pg_field_size($result, 0); 51pg_field_type($result, 0); 52pg_field_prtlen($result, null, 0); 53pg_field_is_null($result, null, 0); 54 55$result = pg_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"); 56pg_result_error($result); 57pg_free_result($result); 58$result = pg_execute($db, "php_test2", array(9999, "A'BC")); 59pg_last_oid($result); 60 61pg_free_result($result); 62pg_close($db); 63 64echo "OK"; 65?> 66--CLEAN-- 67<?php 68include('inc/config.inc'); 69$table_name = "table_24sync_query_prepared"; 70 71$db = pg_connect($conn_str); 72pg_query($db, "DROP TABLE IF EXISTS {$table_name}"); 73?> 74--EXPECT-- 75OK 76