函式名稱:dbase_open()
適用版本:PHP 4, PHP 5, PHP 7
用法:dbase_open() 函式用於開啟一個 dBase 資料庫,並返回一個關聯的資料庫連線控制代碼(資料庫資源)。
語法:resource dbase_open(string $filename, int $mode);
引數:
- $filename:必需,要開啟的 dBase 資料庫檔案的完整路徑和檔名。
- $mode:可選,開啟資料庫的模式。取值為以下幾個常量之一:
- DBASE_RDONLY:只讀模式
- DBASE_RDWR:讀寫模式
- DBASE_CREATE:如果檔案不存在,則建立它
返回值:如果成功,該函式將返回一個表示 dBase 資料庫連線的資源;否則返回 FALSE。
示例:
// 開啟一個 dBase 資料庫檔案 $db = dbase_open('/path/to/database.dbf', DBASE_RDWR);
// 檢查連線是否成功 if ($db) { // 開啟成功 // 可以執行資料庫操作
// 關閉資料庫連線
dbase_close($db);
} else { // 開啟失敗 // 處理錯誤 }