{"record":{"id":"3f0a7ed1351f8448","repo":"phalcon/cphalcon","slug":"resultset-row-class-classname-must-be-a-subcla","errorCode":null,"errorMessage":"Resultset row class '{className}' must be a subclass of Phalcon\\Mvc\\Model\\Row","messagePattern":"Resultset row class '(.+?)' must be a subclass of Phalcon\\\\Mvc\\\\Model\\\\Row","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Query\\Exceptions\\InvalidResultsetRowClass","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":839,"sourceCode":"    {\n        let this->type = type;\n\n        return this;\n    }\n\n    /**\n     * Sets the class used to hydrate rows that are not mapped to a model\n     * (custom columns/joins). The class must be a subclass of\n     * Phalcon\\Mvc\\Model\\Row.\n     */\n    public function setResultsetRowClass(string resultsetRowClass) -> <QueryInterface>\n    {\n        if unlikely !class_exists(resultsetRowClass) {\n            throw new ResultsetRowClassNotFound(resultsetRowClass);\n        }\n\n        if unlikely !is_subclass_of(resultsetRowClass, Row::class) {\n            throw new InvalidResultsetRowClass(resultsetRowClass);\n        }\n\n        let this->resultsetRowClass = resultsetRowClass;\n\n        return this;\n    }\n\n    /**\n     * Tells to the query if only the first row in the resultset must be\n     * returned\n     */\n    public function setUniqueRow(bool uniqueRow) -> <QueryInterface>\n    {\n        let this->uniqueRow = uniqueRow;\n\n        return this;\n    }\n","sourceCodeStart":821,"sourceCodeEnd":857,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L821-L857","documentation":"Query::setResultsetRowClass() validates, after class existence, that the given class is a subclass of Phalcon\\Mvc\\Model\\Row via is_subclass_of(); otherwise InvalidResultsetRowClass is thrown. The faulty input is a valid but non-Row class passed as the hydration target.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:839 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the custom row class extend Phalcon\\Mvc\\Model\\Row","Pass Row::class or a proper subclass","Use hydration to an existing model class instead if rows map to models"],"exampleFix":"class MyRow extends \\Phalcon\\Mvc\\Model\\Row {} $query->setResultsetRowClass(MyRow::class);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare custom row classes as 'class X extends Row' from the start","Add a unit test asserting setResultsetRowClass() accepts only Row subclasses"],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}