Answer the question
In order to leave comments, you need to log in
Yii2. How to override the all() method in an ActiveQuery model?
Hello everybody.
Faced the following problem:
the table has an active field, you need to select only those rows in which the active=1 field is absolutely for all calls to this model.
The solution that I found does not quite suit me (since you have to change this in all calls, and there are a lot of them, and you need to do this for more than one model):
public function allActive(){
$this->andWhere('table_name.active=1')->all();
}
Answer the question
In order to leave comments, you need to log in
And all attempts to write this construction in all() led to errors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question