©
本文档使用
php.cn手册 发布
(PHP 4 >= 4.2.0, PHP 5)
pg_connection_busy — 获知连接是否为忙
$connection
) pg_connection_busy() 在此连接状态为忙的时候返回 TRUE
。如果连接状态为忙,说明前一个查询仍然在执行。如果调用 pg_get_result() 函数的话,则会被锁死。
Example #1 pg_connection_busy() 例子
<?php
$dbconn = pg_connect ( "dbname=publisher" ) or die( "Could not connect" );
$bs = pg_connection_busy ( $dbconn );
if ( $bs ) {
echo 'connection is busy' ;
}
else {
echo 'connection is not busy' ;
}
?>
参见 pg_connection_status() 和 pg_get_result() 。
[#1] levi at alliancesoftware dot com dot au [2009-11-08 17:00:18]
pg_connection_busy() returning true does not necessarily mean that there are results waiting for pg_get_result(); it also stays true for some time after a query that causes any sort of postgres error. (See http://bugs.php.net/bug.php?id=36469)