xref: /PHP-8.4/ext/pgsql/tests/04async_query.phpt (revision beaf1e81)
1--TEST--
2PostgreSQL async query
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("inc/skipif.inc"); ?>
7--FILE--
8<?php
9
10include('inc/config.inc');
11$table_name = "table_04async_query";
12
13$db = pg_connect($conn_str);
14pg_query($db, "CREATE TABLE {$table_name} (num int, str text, bin bytea)");
15pg_query($db, "INSERT INTO {$table_name} DEFAULT VALUES");
16
17if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
18    echo "pg_send_query() error\n";
19}
20while(pg_connection_busy($db));  // busy wait: intended
21if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
22    echo "pg_connection_status() error\n";
23}
24if (!($result = pg_get_result($db)))
25{
26    echo "pg_get_result() error\n";
27}
28
29if (!($rows = pg_num_rows($result))) {
30    echo "pg_num_rows() error\n";
31}
32for ($i=0; $i < $rows; $i++)
33{
34    pg_fetch_array($result, $i, PGSQL_NUM);
35}
36for ($i=0; $i < $rows; $i++)
37{
38    pg_fetch_object($result);
39}
40for ($i=0; $i < $rows; $i++)
41{
42    pg_fetch_row($result, $i);
43}
44for ($i=0; $i < $rows; $i++)
45{
46    pg_fetch_result($result, $i, 0);
47}
48
49pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
50pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
51pg_field_name($result, 0);
52pg_field_num($result, "num");
53pg_field_size($result, 0);
54pg_field_type($result, 0);
55pg_field_prtlen($result, 0);
56pg_field_is_null($result, 0);
57
58if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
59{
60    echo "pg_send_query() error\n";
61}
62
63pg_last_oid($result);
64pg_free_result($result);
65
66
67echo "OK";
68?>
69--CLEAN--
70<?php
71include('inc/config.inc');
72$table_name = "table_04async_query";
73
74$db = pg_connect($conn_str);
75pg_query($db, "DROP TABLE IF EXISTS {$table_name}");
76?>
77--EXPECTF--
78Deprecated: Calling pg_field_prtlen() with 2 arguments is deprecated, use the 3-parameter signature with a null $row parameter instead in %s on line %d
79
80Deprecated: Calling pg_field_is_null() with 2 arguments is deprecated, use the 3-parameter signature with a null $row parameter instead in %s on line %d
81OK
82