Answer the question
In order to leave comments, you need to log in
How to update a record in a model without calling before save?
How to do this in Yii2?
$data = Cars::find()->where(['id_car' => 100])->one();
$data >car_price = 150;
$data>save(false);
But so that there is no call to before save in the model.
Answer the question
In order to leave comments, you need to log in
$data >save(false);
this is saving without validation, before save will still work.
If you need to bypass before save and other events, then you should do this:
www.yiiframework.com/doc-2.0/yii-db-activerecord.h...
I didn’t quite understand: you already have an overridden beforeSave in the model with some kind of logic and you just need to turn it off in one place?
upd: If so, add the useBeforeSave flag to the model and check if (!$this->useBeforeSave) { return true; } at first.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question