版本: v2.3.0
replace
替換資料表中的記錄。若存在主鍵相同的記錄,會先刪除再重新插入;否則會插入一筆新記錄。
replace($table, $columns, $where)
table [string]
資料表名稱。
columns [array]
定義替換內容的欄位值對映。
where [array] (可選)
用於篩選目標記錄的 WHERE 條件。
回傳值
[PDOStatement] 已執行查詢的 PDOStatement 實例。
$database->replace("account", [
"type" => [
"user" => "new_user",
"business" => "new_business"
],
"column" => [
"old_value" => "new_value"
]
], [
"user_id[>]" => 1000
]);