1--TEST--
2PostgreSQL sync query params
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_23sync_query_params";
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
19$result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
20if (!($rows   = pg_num_rows($result)))
21{
22	echo "pg_num_row() error\n";
23}
24for ($i=0; $i < $rows; $i++)
25{
26	pg_fetch_array($result, $i, PGSQL_NUM);
27}
28for ($i=0; $i < $rows; $i++)
29{
30	pg_fetch_object($result);
31}
32for ($i=0; $i < $rows; $i++)
33{
34	pg_fetch_row($result, $i);
35}
36for ($i=0; $i < $rows; $i++)
37{
38	pg_fetch_result($result, $i, 0);
39}
40
41pg_result_error($result);
42pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
43pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
44pg_field_name($result, 0);
45pg_field_num($result, "num");
46pg_field_size($result, 0);
47pg_field_type($result, 0);
48pg_field_prtlen($result, null, 0);
49pg_field_is_null($result, null, 0);
50
51$result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
52pg_last_oid($result);
53
54pg_free_result($result);
55pg_close($db);
56
57echo "OK";
58?>
59--CLEAN--
60<?php
61include('inc/config.inc');
62$table_name = "table_23sync_query_params";
63
64$db = pg_connect($conn_str);
65pg_query($db, "DROP TABLE IF EXISTS {$table_name}");
66?>
67--EXPECT--
68OK
69