Open aywan opened 2 years ago
Please can you provide an example of the issue encountered without adding $db
to one()
and all()
I usually override ActiveRecord::find with concrete class. It useful for typing.
<?php
/**
* @method array|Profile one($db = null)
* @method array|Profile[] all($db = null)
* @method array|\Generator|Profile[] each($batchSize = 100, $db = null)
*/
class ProfileActiveQuery extends ActiveQuery
{
public function __construct(array $config = [])
{
parent::__construct(Profile::class, $config);
}
}
For example when id do $profiles = Profile::find()->where(...)->all()
- everyone tool know $profiles is Profile[]
type.
Inside Yii2 sources - interface also has $db attribute in this methods https://github.com/yiisoft/yii2/blob/master/framework/db/ActiveQueryInterface.php#L40
Without this have troubles when inherit Query object. Don't know how write tests)