pg_fetch_all
(PHP 4 >= 4.3.0, PHP 5)
pg_fetch_all — Fetches all rows from a result as an array
Descripción
array pg_fetch_all
( resource
$result
)pg_fetch_all() returns an array that contains all rows (records) in the result resource.
Nota: Esta función define campos NULOS al valor
NULLde PHP.
Parámetros
-
result -
PostgreSQL query result resource, returned by pg_query(), pg_query_params() or pg_execute() (among others).
Valores devueltos
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.
Ejemplos
Ejemplo #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);
?>
El resultado del ejemplo sería algo similar a:
Array
(
[0] => Array
(
[id] => 1
[name] => Fred
)
[1] => Array
(
[id] => 2
[name] => Bob
)
)
Ver también
- pg_fetch_row() - Get a row as an enumerated array
- pg_fetch_array() - Fetch a row as an array
- pg_fetch_object() - Fetch a row as an object
- pg_fetch_result() - Returns values from a result resource