我有以下INSERT:
$id = \DB::table('log')
->insert(array(
"account_id" => $this->get("account_id"),
"type" => "Edit info",
"done" => "0"
));
我如何调整它以便仅在日志表中没有以前的条目时才执行?
account_id:1 //
类型:编辑信息//
完成:0
我需要避免重复输入(如果用户已经请求编辑他/她的信息并且尚未由管理员完成,则不要重复输入)。
最佳答案
您可以使用updateOrInsert
方法。
$id = \DB::table('log')->updateOrInsert(array(
"account_id" => $this->get("account_id"),
"type" => "Edit info",
"done" => "0"
));