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