pg_fetch_all
(PHP 4 >= 4.3.0, PHP 5, PHP 7)
pg_fetch_all - 从结果中获取所有行作为数组
描述
array pg_fetch_all ( resource $result )
pg_fetch_all()返回一个包含结果资源中所有行(记录)的数组。
注意:该函数将NULL字段设置为PHP
NULL
值。
参数
result
PostgreSQL查询结果资源,由pg_query(),pg_query_params()或pg_execute()等返回。
返回值
结果中包含所有行的数组。每行是由字段名称索引的字段值数组。
FALSE
如果结果中没有行或任何其他错误,则返回。
例子
Example #1 PostgreSQL fetch all
<?php?
$conn?=?pg_pconnect("dbname=publisher");
if?(!$conn)?{
????echo?"An?error?occurred.\n";
????exit;
}
$result?=?pg_query($conn,?"SELECT?*?FROM?authors");
if?(!$result)?{
????echo?"An?error?occurred.\n";
????exit;
}
$arr?=?pg_fetch_all($result);
print_r($arr);
?>
上面的例子会输出类似于:
Array
(
[0] => Array
(
[id] => 1
[name] => Fred
)
[1] => Array
(
[id] => 2
[name] => Bob
)
)
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com