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