Answer the question
In order to leave comments, you need to log in
Yii2. How to change the value of an attribute for all records in a table?
I do like this:
$models = Table::findAll(['type'=>$type]);
foreach ($models as $model) {
$model->value = 0;
$model->save();
}
Answer the question
In order to leave comments, you need to log in
from off. docs www.yiiframework.com/doc-2.0/yii-db-activerecord.h ...
Customer::updateAll(['status' => 1], 'status = 2');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question