Forum und email

pg_fetch_all

(PHP 4 >= 4.3.0, PHP 5)

pg_fetch_all — Fetches all rows from a result as an array

說明

array pg_fetch_all ( resource $result )

pg_fetch_all() returns an array that contains all rows (records) in the result resource.

Note: 本函式對 PHP NULL 值設定 NULL 字段。

參數

result

PostgreSQL query result resource, returned by pg_query(), pg_query_params() or pg_execute() (among others).

Return值

An array with all rows in the result. Each row is an array of field values indexed by field name.

FALSE is returned if there are no rows in the result, or on any other error.

範例

Example#1 PostgreSQL fetch all

<?php 
$conn 
pg_pconnect("dbname=publisher");
if (!
$conn) {
  echo 
"An error occured.\n";
  exit;
}

$result pg_query($conn"SELECT * FROM authors");
if (!
$result) {
  echo 
"An error occured.\n";
  exit;
}

$arr pg_fetch_all($result);

var_dump($arr);

?>