我想用模型更新一個(gè)表的全部數(shù)據(jù),但是必須加個(gè)where條件才可以更新, 直接去掉where就會(huì)報(bào)錯(cuò)Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically, assuming $this from incompatible context。加這個(gè)where看著又別扭,且沒啥實(shí)際意義,代碼如下:
Goods::where(DB::raw(1), 1)->update([
'start_time' => $start_time
]);
能去掉這個(gè)where嘛?試過用 (new Goods)->update(['start_time' => $start_time]),但是實(shí)際沒任何sql執(zhí)行, 也不想用DB::table('goods')->update()這種更新方式~.
- 2 回答
- 0 關(guān)注
- 919 瀏覽
添加回答
舉報(bào)
0/150
提交
取消