pg_fetch_row
(PHP 4, PHP 5, PHP 7, PHP 8)
pg_fetch_row — 提取一行作為列舉陣列
說明
   pg_fetch_row(resource 
    $result, int $row = ?): array
     pg_fetch_row() 根據指定的 result 資源提取一行數據(記錄)作為陣列返回。每個得到的列依次存放在陣列中,從偏移量 0 開始。
    
注意: 此函式將 NULL 欄位設定為 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.
  
   返回的陣列和提取的行相一致。如果沒有更多行 row 可提取,則返回 false。
  
更新日誌
| 版本 | 說明 | 
|---|---|
| 4.1.0 | 
        參數 row 成為可選參數。
        | 
      
範例
示例 #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";
}
 
?>
參見
- pg_query() - 執行查詢
 - pg_fetch_array() - 提取一行作為陣列
 - pg_fetch_object() - 提取一行作為對像
 - pg_fetch_result() - 從結果資源中返回值