我有以下插入: $id = \DB::table('log') ->insert(array( "account_id" => $this->get("account_id"), "type" => "Edit info", "done" => "0" ));我如何調整它以便僅在日志表中沒有像這樣的先前條目時才執(zhí)行?account_id: 1 // 類型:編輯信息 // 完成: 0我需要避免重復輸入(如果用戶已經請求編輯他/她的信息并且尚未由管理員完成,則沒有相同的條目)。
1 回答

寶慕林4294392
TA貢獻2021條經驗 獲得超8個贊
您可以使用updateOrInsert方法。
$id = \DB::table('log')->updateOrInsert(array(
"account_id" => $this->get("account_id"),
"type" => "Edit info",
"done" => "0"
));
- 1 回答
- 0 關注
- 145 瀏覽
添加回答
舉報
0/150
提交
取消