yiisoft/yii2 · error · InvalidConfigException
The "query" property must be an instance of a class that imp
Error message
The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.
What it means
Error "The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses." thrown in yiisoft/yii2.
Source
Thrown at framework/data/ActiveDataProvider.php:102
* Initializes the DB connection component.
* This method will initialize the [[db]] property (when set) to make sure it refers to a valid DB connection.
* @throws InvalidConfigException if [[db]] is invalid.
*/
public function init()
{
parent::init();
if ($this->db !== null) {
$this->db = Instance::ensure($this->db);
}
}
/**
* {@inheritdoc}
*/
protected function prepareModels()
{
if (!$this->query instanceof QueryInterface) {
throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.');
}
$query = clone $this->query;
if (($pagination = $this->getPagination()) !== false) {
$pagination->totalCount = $this->getTotalCount();
if ($pagination->totalCount === 0) {
return [];
}
$query->limit($pagination->getLimit())->offset($pagination->getOffset());
}
if (($sort = $this->getSort()) !== false) {
$query->addOrderBy($sort->getOrders());
}
return $query->all($this->db);
}
/**
* {@inheritdoc}View on GitHub (pinned to 66f00d18a2)
When it happens
Trigger: Thrown at framework/data/ActiveDataProvider.php:102 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/3eb7f9250d42e242.
Report an issue: GitHub.