thinkphp 5.1模型删除 注意事项
像下边这种是不生效的。

User::where('field1','op1')->where('field2','op2')->delete();

下边这样才生效。
多种where条件组合的话,需要使用destroy 方法,或者查出来主键,直接给到destroy方法里删除

 RemindRecord::destroy(function ($query) use ($id){
                $query->where('loop_id',$id)->where('is_done',0);
            });

模型删除,尤其是软删除。要用destroy 方法,能指定主键最好指定主键值删除,条件删除的话必须使用闭包传入where 条件。

相关文章:

  • 2021-11-19
  • 2021-05-30
  • 2021-11-02
  • 2021-09-18
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
猜你喜欢
  • 2021-05-16
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2022-02-19
  • 2022-12-23
相关资源
相似解决方案