PHP Conference Japan 2024

dba_exists

(PHP 4, PHP 5, PHP 7, PHP 8)

dba_exists檢查鍵值是否存在

說明

dba_exists(字串|陣列 $key, Dba\Connection $dba): 布林值

dba_exists() 檢查指定的 key 是否存在於資料庫中。

參數

key (鍵值)

要檢查的鍵值。

dba

一個 Dba\Connection 實例,由 dba_open()dba_popen() 返回。

返回值

如果鍵值存在,則返回 true,否則返回 false

更新日誌

版本 說明
8.4.0 dba 參數現在需要一個 Dba\Connection 實例;以前,需要一個有效的 dba 資源

參見

新增筆記

使用者貢獻的筆記 1 則筆記

frenzy dot ivan at gmail dot com
16 年前
<?php

$index
= 4;
$id = dba_open("frenzy.db", "w", "flatfile");
if(!
$id) exit ("發生錯誤...");
if(
dba_exists($index, $id)) exit ("此鍵值已被使用");
dba_close($id);

?>
To Top