xref: /PHP-5.5/ext/pgsql/tests/04async_query.phpt (revision f6239c33)
1--TEST--
2PostgreSQL async query
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--FILE--
6<?php
7
8include('config.inc');
9
10$db = pg_connect($conn_str);
11
12if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
13	echo "pg_send_query() error\n";
14}
15while(pg_connection_busy($db));  // busy wait: intended
16if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
17	echo "pg_connection_status() error\n";
18}
19if (!($result = pg_get_result($db)))
20{
21	echo "pg_get_result() error\n";
22}
23
24if (!($rows = pg_num_rows($result))) {
25	echo "pg_num_rows() error\n";
26}
27for ($i=0; $i < $rows; $i++)
28{
29	pg_fetch_array($result, $i, PGSQL_NUM);
30}
31for ($i=0; $i < $rows; $i++)
32{
33	pg_fetch_object($result);
34}
35for ($i=0; $i < $rows; $i++)
36{
37	pg_fetch_row($result, $i);
38}
39for ($i=0; $i < $rows; $i++)
40{
41	pg_fetch_result($result, $i, 0);
42}
43
44pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
45pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
46pg_field_name($result, 0);
47pg_field_num($result, $field_name);
48pg_field_size($result, 0);
49pg_field_type($result, 0);
50pg_field_prtlen($result, 0);
51pg_field_is_null($result, 0);
52
53if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
54{
55	echo "pg_send_query() error\n";
56}
57
58pg_last_oid($result);
59pg_free_result($result);
60
61
62echo "OK";
63?>
64--EXPECT--
65OK
66