(PHP 4, PHP 5, PHP 7, PHP 8)
pg_fetch_row — Get a row as an enumerated array
pg_fetch_row() fetches one row of data from
the result associated with the specified result
instance.
Зауваження: Ця функція встановлює NULL-полям значення PHP
null
.
result
Примірник PgSql\Result, якого повертає одна з функцій pg_query(), pg_query_params() або pg_execute() (серед інших).
row
Row number in result to fetch. Rows are numbered from 0 upwards. If
omitted or null
, the next row is fetched.
mode
Необов'язковий параметр, яким
вказується спосіб індексування масиву (array).
mode
може мати значення однієї з констант:
PGSQL_ASSOC
, PGSQL_NUM
або
PGSQL_BOTH
. Якщо задано PGSQL_NUM
, то
функція поверне масив з числовими індексами; якщо
PGSQL_ASSOC
, то з асоціативними індексами; якщо
PGSQL_BOTH
, то і з числовими, і з асоціативними
індексами.
An array, indexed from 0 upwards, with each value
represented as a string. Database NULL
values are returned as null
.
false
is returned if row
exceeds the number
of rows in the set, there are no more rows, or on any other error.
Версія | Опис |
---|---|
8.1.0 |
Тепер параметр result має бути примірником
PgSql\Result. Раніше очікувався resource.
|
Приклад #1 pg_fetch_row() example
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
$result = pg_query($conn, "SELECT author, email FROM authors");
if (!$result) {
echo "An error occurred.\n";
exit;
}
while ($row = pg_fetch_row($result)) {
echo "Author: $row[0] E-mail: $row[1]";
echo "<br />\n";
}
?>