LaravelConf Taiwan 2020 CFP Started

pg_fetch_all

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

pg_fetch_allFetches all rows from a result as an array

Descrierea

pg_fetch_all ( resource $result [, int $result_type = PGSQL_ASSOC ] ) : array

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

Notă: Această funcție stabilește câmpurile NULL la valoarea PHP NULL.

Parametri

result

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

Valorile întoarse

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.

Exemple

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);

?>

Exemplul de mai sus va afișa ceva similar cu:

Array
(
    [0] => Array
        (
            [id] => 1
            [name] => Fred
        )

    [1] => Array
        (
            [id] => 2
            [name] => Bob
        )

)

Istoricul schimbărilor

Versiune Descriere
7.1.0 The result_type parameter was added.

A se vedea și

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top