(PHP 4, PHP 5, PHP 7, PHP 8)
pg_fetch_row — 提取一行作為枚舉數(shù)組
$result
, int $row
= ?): array
pg_fetch_row() 根據(jù)指定的 result
資源提取一行數(shù)據(jù)(記錄)作為數(shù)組返回。每個(gè)得到的列依次存放在數(shù)組中,從偏移量 0 開始。
注意: 此函數(shù)將 NULL 字段設(shè)置為 PHP
null
值。
result
PostgreSQL query result resource, returned by pg_query(), pg_query_params() or pg_execute() (among others).
row
Row number in result to fetch. Rows are numbered from 0 upwards. If
omitted or null
, the next row is fetched.
An array, indexed from 0 upwards, with each value
represented as a string. Database NULL
values are returned as null
.
返回的數(shù)組和提取的行相一致。如果沒有更多行 row
可提取,則返回 false
。
版本 | 說明 |
---|---|
4.1.0 |
參數(shù) row 成為可選參數(shù)。
|
示例 #1 pg_fetch_row() 例子
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occured.\n";
exit;
}
$result = pg_query($conn, "SELECT author, email FROM authors");
if (!$result) {
echo "An error occured.\n";
exit;
}
while ($row = pg_fetch_row($result)) {
echo "Author: $row[0] E-mail: $row[1]";
echo "<br />\n";
}
?>