dbase_replace_record
(PHP 5 < 5.3.0, dbase 5, dbase 7)
dbase_replace_record — 데이터베이스의 레코드를 대체합니다.
설명
dbase_replace_record(resource $database
, array $data
, int $number
): bool
데이터베이스의 주어진 레코드를 주어진 데이터로 바꿉니다.
매개변수
database
- dbase_open() 또는 dbase_create()에 의해 반환된 데이터베이스 리소스입니다.
data
- 인덱싱된 데이터 배열입니다. 항목 수는 데이터베이스의 필드 수와 같아야 합니다. 그렇지 않으면 dbase_replace_record()가 실패합니다.
메모: 이 매개변수에 dbase_get_record() 반환 값을 사용하는 경우 삭제된 키를 재설정하는 것을 잊지 마십시오.
number
- 1에서 데이터베이스의 레코드 수(dbase_numrecords()에서 반환됨)까지의 정수입니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
dbase 7.0.0 | database 는 이제 int 대신 리소스입니다. |
Examples
예제 #1 데이터베이스의 레코드 업데이트
<?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);
}
?>
노트
메모: 부울 필드는 dbase_get_record() 또는 dbase_get_record_with_names()를 통해 검색할 때 int 요소 값(0
또는 1
)이 됩니다. 다시 기록하면 값이 0
이 되므로 값을 적절하게 조정하도록 주의해야 합니다.
기타
- dbase_add_record() - 데이터베이스에 레코드를 추가합니다.
- dbase_delete_record() - 데이터베이스에서 레코드 삭제