我有以下插入: $id = \DB::table('log') ->insert(array( "account_id" => $this->get("account_id"), "type" => "Edit info", "done" => "0" ));我如何调整它以便仅在日志表中没有像这样的先前条目时才执行?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 关注
- 131 浏览
添加回答
举报
0/150
提交
取消