pg_fetch_assoc
pg_fetch_assoc
Fetch a row as an associative array
**pg_fetch_assoc** PgSql\Result $result $row
returns an associative array that
corresponds to the fetched row (records).
pg_fetch_assoc
is equivalent to calling
with as the
optional third parameter. It only returns an associative array.
If you need the numeric indices, use
.
pg_fetch_assoc``pg_fetch_array``PGSQL_ASSOC``pg_fetch_row
is NOT significantly
slower than using , and
is significantly easier to use.
pg_fetch_assoc``pg_fetch_row
result``rowRow number in result to fetch. Rows are numbered from 0 upwards. If
omitted or null, the next row is fetched.
An indexed associatively (by field name).
Each value in the is represented as a
. Database
values are returned as null.
array``array``string``NULL
false is returned if exceeds the number
of rows in the set, there are no more rows, or on any other error.
row
Voorbeeld: example
<?php
$conn = pg_connect("dbname=publisher");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
$result = pg_query($conn, "SELECT id, author, email FROM authors");
if (!$result) {
echo "An error occurred.\n";
exit;
}
while ($row = pg_fetch_assoc($result)) {
echo $row['id'];
echo $row['author'];
echo $row['email'];
}
?>
pg_fetch_row``pg_fetch_array``pg_fetch_object``pg_fetch_result