pg_result_status
(PHP 4 >= 4.2.0, PHP 5, PHP 7)
pg_result_status - 获取查询结果的状态
描述
mixed pg_result_status ( resource $result [, int $type = PGSQL_STATUS_LONG ] )
pg_result_status()返回结果资源的状态,或者返回与结果相关的PostgreSQL命令完成标记
参数
result
PostgreSQL查询结果资源,由pg_query(),pg_query_params()或pg_execute()等返回。
type
要么PGSQL_STATUS_LONG
返回该的数字状态result
,要么PGSQL_STATUS_STRING
返回该命令的标签result
。如果未指定,PGSQL_STATUS_LONG
则为默认值。
返回值
可能的返回值为PGSQL_EMPTY_QUERY
,PGSQL_COMMAND_OK
,PGSQL_TUPLES_OK
,PGSQL_COPY_OUT
,PGSQL_COPY_IN
,PGSQL_BAD_RESPONSE
,PGSQL_NONFATAL_ERROR
以及PGSQL_FATAL_ERROR
如果PGSQL_STATUS_LONG
被指定。否则,返回一个包含PostgreSQL命令标签的字符串。
例子
示例#1 pg_result_status()示例
<?php
//?Connect?to?the?database
$conn?=?pg_pconnect("dbname=publisher");
//?Execute?a?COPY
$result?=?pg_query($conn,?"COPY?authors?FROM?STDIN;");
//?Get?the?result?status
$status?=?pg_result_status($result);
//?Determine?status
if?($status?==?PGSQL_COPY_IN)
???echo?"Copy?began.";
else
???echo?"Copy?failed.";
?
?>
上面的例子将输出:
Copy began.
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com