我想用模型更新一个表的全部数据,但是必须加个where条件才可以更新, 直接去掉where就会报错Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically, assuming $this from incompatible context。加这个where看着又别扭,且没啥实际意义,代码如下:
Goods::where(DB::raw(1), 1)->update([
'start_time' => $start_time
]);
能去掉这个where嘛?试过用 (new Goods)->update(['start_time' => $start_time]),但是实际没任何sql执行, 也不想用DB::table('goods')->update()这种更新方式~.
添加回答
举报
0/150
提交
取消