pg_get_result
pg_get_result
(PHP 4 >= 4.2.0, PHP 5, PHP 7)
pg_get_result - 获取异步查询结果
描述
resource pg_get_result ([ resource $connection ] )
pg_get_result()
从由pg_send_query(),pg_send_query_params()或pg_send_execute()执行的异步查询获取结果资源。
pg_send_query()和其他异步查询函数可以向PostgreSQL服务器发送多个查询,并且使用pg_get_result()
来逐个获取每个查询的结果。
参数
connection
PostgreSQL数据库连接资源。
返回值
返回结果资源,或当没有更多可用结果时返回FALSE
。
示例
示例#1 pg_get_result()示例
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect"
if (!pg_connection_busy($dbconn)) {
pg_send_query($dbconn, "select * from authors; select count(*) from authors;"
}
$res1 = pg_get_result($dbconn
echo "First call to pg_get_result(): $res1\n";
$rows1 = pg_num_rows($res1
echo "$res1 has $rows1 records\n\n";
$res2 = pg_get_result($dbconn
echo "Second call to pg_get_result(): $res2\n";
$rows2 = pg_num_rows($res2
echo "$res2 has $rows2 records\n";
?>
上面的例子将输出:
First call to pg_get_result(): Resource id #3
Resource id #3 has 3 records
Second call to pg_get_result(): Resource id #4
Resource id #4 has 1 records
扩展内容
- pg_send_query() - 发送异步查询
← pg_get_pid
pg_host →