{"record":{"id":"3eb7f9250d42e242","repo":"yiisoft/yii2","slug":"the-query-property-must-be-an-instance-of-a-clas","errorCode":null,"errorMessage":"The \"query\" property must be an instance of a class that implements the QueryInterface e.g. yii\\db\\Query or its subclasses.","messagePattern":"The \"query\" property must be an instance of a class that implements the QueryInterface e\\.g\\. yii\\\\db\\\\Query or its subclasses\\.","errorType":"exception","errorClass":"InvalidConfigException","httpStatus":null,"severity":"error","filePath":"framework/data/ActiveDataProvider.php","lineNumber":102,"sourceCode":"     * Initializes the DB connection component.\n     * This method will initialize the [[db]] property (when set) to make sure it refers to a valid DB connection.\n     * @throws InvalidConfigException if [[db]] is invalid.\n     */\n    public function init()\n    {\n        parent::init();\n        if ($this->db !== null) {\n            $this->db = Instance::ensure($this->db);\n        }\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    protected function prepareModels()\n    {\n        if (!$this->query instanceof QueryInterface) {\n            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.');\n        }\n        $query = clone $this->query;\n        if (($pagination = $this->getPagination()) !== false) {\n            $pagination->totalCount = $this->getTotalCount();\n            if ($pagination->totalCount === 0) {\n                return [];\n            }\n            $query->limit($pagination->getLimit())->offset($pagination->getOffset());\n        }\n        if (($sort = $this->getSort()) !== false) {\n            $query->addOrderBy($sort->getOrders());\n        }\n\n        return $query->all($this->db);\n    }\n\n    /**\n     * {@inheritdoc}","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/data/ActiveDataProvider.php#L84-L120","documentation":"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.","triggerScenarios":"Thrown at framework/data/ActiveDataProvider.php:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}