W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
(PF5 < 5.3.0、dBASE 5、dBASE 7)
dbase_replace_record — 替換數(shù)據(jù)庫中的記錄
dbase_replace_record(resource $database, array $data, int $number): bool
將數(shù)據(jù)庫中的給定記錄替換為給定數(shù)據(jù)。
database
由 dbase_open() 或 dbase_create() 返回的數(shù)據(jù)庫資源。
data
索引數(shù)據(jù)數(shù)組。項目數(shù)必須等于 數(shù)據(jù)庫中的字段數(shù),否則 dbase_replace_record() 將失敗。
注意:
如果您為此使用 dbase_get_record() 返回值 參數(shù),記得重置名為 .
deleted
number
從 1 到數(shù)據(jù)庫中記錄數(shù)的整數(shù) (由 dbase_numrecords() 返回)。
成功時返回 true, 或者在失敗時返回 false。
版本 | 說明 |
---|---|
dbase 7.0.0 | database 現(xiàn)在是資源而不是整數(shù)。 |
示例 #1 更新數(shù)據(jù)庫中的記錄
<?php
// open in read-write mode
$db = dbase_open('/tmp/test.dbf', 2);
if ($db) {
// gets the old row
$row = dbase_get_record_with_names($db, 1);
// remove the 'deleted' entry
unset($row['deleted']);
// Update the date field with the current timestamp
$row['date'] = date('Ymd');
// convert the row to an indexed array
$row = array_values($row);
// Replace the record
dbase_replace_record($db, $row, 1);
dbase_close($db);
}
?>
注意:布爾字段生成 int 元素值 ( 或 ) 通過 dbase_get_record() 或 dbase_get_record_with_names() 檢索時。如果他們被寫回去, 這導(dǎo)致值成為 ,所以必須小心 用于正確調(diào)整值。010
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: