pg_fetch_row

(PHP 4, PHP 5, PHP 7, PHP 8)

pg_fetch_row提取一行作為枚舉數(shù)組

說(shuō)明

pg_fetch_row(resource $result, int $row = ?): array

pg_fetch_row() 根據(jù)指定的 result 資源提取一行數(shù)據(jù)(記錄)作為數(shù)組返回。每個(gè)得到的列依次存放在數(shù)組中,從偏移量 0 開(kāi)始。

注意: 此函數(shù)將 NULL 字段設(shè)置為 PHP null 值。

參數(shù)

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ù)組和提取的行相一致。如果沒(méi)有更多行 row 可提取,則返回 false。

更新日志

版本 說(shuō)明
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";
}
 
?>

參見(jiàn)