php-src/ext/pgsql/tests/04async_query.phpt

66 lines
1.3 KiB
Plaintext
Raw Normal View History

2001-12-17 08:16:48 +08:00
--TEST--
PostgreSQL async query
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php
2003-05-20 08:14:46 +08:00
include('config.inc');
$db = pg_connect($conn_str);
if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
2020-02-04 05:52:20 +08:00
echo "pg_send_query() error\n";
2003-05-20 08:14:46 +08:00
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
2020-02-04 05:52:20 +08:00
echo "pg_connection_status() error\n";
2003-05-20 08:14:46 +08:00
}
2018-09-17 01:16:42 +08:00
if (!($result = pg_get_result($db)))
2003-05-20 08:14:46 +08:00
{
2020-02-04 05:52:20 +08:00
echo "pg_get_result() error\n";
2003-05-20 08:14:46 +08:00
}
if (!($rows = pg_num_rows($result))) {
2020-02-04 05:52:20 +08:00
echo "pg_num_rows() error\n";
2003-05-20 08:14:46 +08:00
}
2018-09-17 01:16:42 +08:00
for ($i=0; $i < $rows; $i++)
2003-05-20 08:14:46 +08:00
{
2020-02-04 05:52:20 +08:00
pg_fetch_array($result, $i, PGSQL_NUM);
2003-05-20 08:14:46 +08:00
}
2018-09-17 01:16:42 +08:00
for ($i=0; $i < $rows; $i++)
2003-05-20 08:14:46 +08:00
{
2020-02-04 05:52:20 +08:00
pg_fetch_object($result);
2003-05-20 08:14:46 +08:00
}
2018-09-17 01:16:42 +08:00
for ($i=0; $i < $rows; $i++)
2003-05-20 08:14:46 +08:00
{
2020-02-04 05:52:20 +08:00
pg_fetch_row($result, $i);
2003-05-20 08:14:46 +08:00
}
2018-09-17 01:16:42 +08:00
for ($i=0; $i < $rows; $i++)
2003-05-20 08:14:46 +08:00
{
2020-02-04 05:52:20 +08:00
pg_fetch_result($result, $i, 0);
2003-05-20 08:14:46 +08:00
}
pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_field_name($result, 0);
pg_field_num($result, $field_name);
pg_field_size($result, 0);
pg_field_type($result, 0);
pg_field_prtlen($result, 0);
pg_field_is_null($result, 0);
2018-09-17 01:16:42 +08:00
if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
2003-05-20 08:14:46 +08:00
{
2020-02-04 05:52:20 +08:00
echo "pg_send_query() error\n";
2003-05-20 08:14:46 +08:00
}
pg_last_oid($result);
pg_free_result($result);
echo "OK";
2001-12-17 08:16:48 +08:00
?>
--EXPECT--
OK