PHP8 dbase_get_record_with_names

2024-03-30 21:12 更新

(PHP 5 < 5.3.0、dbase 5、dbase 7)

dbase_get_record_with_names — 從數(shù)據(jù)庫中獲取作為關(guān)聯(lián)數(shù)組的記錄

說明

dbase_get_record_with_names(resource $database, int $number): array

從 dBase 數(shù)據(jù)庫中獲取作為關(guān)聯(lián)數(shù)組的記錄。

參數(shù) 

database

由 dbase_open() 或 dbase_create() 返回的數(shù)據(jù)庫資源。

number

和 之間的記錄索引。1dbase_numrecords($dbase_identifier)

返回值 

與記錄的關(guān)聯(lián)數(shù)組。這還將包括一個(gè)名為的鍵,如果記錄已標(biāo)記,則設(shè)置為 1 刪除(見dbase_delete_record())。 因此,無法檢索以此函數(shù)命名的字段的值。deleteddeleted

每個(gè)字段都會(huì)被轉(zhuǎn)換為對(duì)應(yīng)的 PHP 類型,除了以下場(chǎng)景:

  • 日期會(huì)被轉(zhuǎn)換成字符串。
  • DateTime 會(huì)被轉(zhuǎn)換成字符串。
  • 范圍之外的整數(shù) PHP_INT_MIN.. PHP_INT_MAX 將返回字符串。
  • dbase 7.0.0 之前的版本, 布爾型 (L) 將被轉(zhuǎn)換為 1 或 0。

出錯(cuò)時(shí),dbase_get_record_with_names() 將返回 false。

更新日志 

版本說明
dbase 7.0.0database現(xiàn)在是資源而不是整數(shù)。

示例 

示例 #1 列出數(shù)據(jù)庫中的所有注冊(cè)成員

<?php
// open in read-only mode
$db = dbase_open('/tmp/test.dbf', 0);

if ($db) {
  $record_numbers = dbase_numrecords($db);
  for ($i = 1; $i <= $record_numbers; $i++) {
      $row = dbase_get_record_with_names($db, $i);
      if ($row['ismember'] == 1) {
          echo "Member #$i: " . trim($row['name']) . "\n";
      }
  }
}
?>

參見 

  • dbase_get_record() - 從數(shù)據(jù)庫中獲取索引數(shù)組的記錄


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)