How to do batchUpdate in yii2

sapo picture sapo · Apr 17, 2015 · Viewed 13k times · Source

Only batchInsert is available in yii2, bacthUpdate is not available in yii2, how can we do this in yii2 like Codeigniter batchUpdate?

Answer

Mike Kaharlykskiy picture Mike Kaharlykskiy · Mar 17, 2018

Use updateAll() on your model.

Customer::updateAll(['status' => 1], 'status = 2');

From Yii 2 documentation

Hope it helps!