Could you provide an example usage. Description will be highly appreciated. I can not find a good example for it.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
The Active Query represents a DB query associated with an Active Record class. It is usually used to override the default
find()
method of a specific model where it will be used to generate the query before sending to DB :If you worked before with Yii 1 then this is what replaces Yii 1.x Named Scopes in Yii2. All you have to do is to override the
find()
method in your model class to use the ActiveQuery class above :Then you can use it this way :
A different use case of the same ActiveQuery class defined above is by using it when defining relational data in a related model class like:
Then you can eager load customers with their respective payed orders by doing :