array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'function.pg-fetch-all.php', 1 => 'pg_fetch_all', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL İşlevleri', ), 'prev' => array ( 0 => 'function.pg-fetch-all-columns.php', 1 => 'pg_fetch_all_columns', ), 'next' => array ( 0 => 'function.pg-fetch-array.php', 1 => 'pg_fetch_array', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/pgsql/functions/pg-fetch-all.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
pg_fetch_all — Fetches all rows from a result as an array
pg_fetch_all() returns an array that contains all rows (records) in the PgSql\Result instance.
Bilginize: Bu işlev NULL alanlara PHP
null
değerini atar.
result
pg_query(), pg_query_params() veya pg_execute() işlevinden dönen PgSql\Result nesnesi.
mode
Dizinin nasıl indisleneceğini belirleyen seçimlik bağımsız değişken.
kip
bir sabit olup şu değerleri alabilir:
PGSQL_ASSOC
, PGSQL_NUM
ve
PGSQL_BOTH
.
PGSQL_NUM
ile işlev sayısal indisli bir dizi,
PGSQL_ASSOC
ile ilişkisel bir dizi ve
PGSQL_BOTH
ile hem sayısal hem de ilişkisel indisli bir
dizi döndürür.
An array with all rows in the result. Each row is an array of field values indexed by field name.
Sürüm: | Açıklama |
---|---|
8.1.0 |
sonuç bağımsız değişkeni artık
PgSql\Result nesnesi kabul ediyor, evvelce bir
özkaynak kabul ederdi.
|
8.0.0 |
pg_fetch_all() will now return an empty array
instead of false for result sets with zero rows.
|
7.1.0 |
The mode parameter was added.
|
Örnek 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);
?>
Yukarıdaki örnek şuna benzer bir çıktı üretir:
Array ( [0] => Array ( [id] => 1 [name] => Fred ) [1] => Array ( [id] => 2 [name] => Bob ) )