phalcon/cphalcon · error · Phalcon\Mvc\Model\Query\Exceptions\InvalidResultsetRowClass

Resultset row class ' ' must be a subclass of…

Error message

Resultset row class '{className}' must be a subclass of Phalcon\Mvc\Model\Row

What it means

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.

Solutions

  1. Make the custom row class extend Phalcon\Mvc\Model\Row
  2. Pass Row::class or a proper subclass
  3. Use hydration to an existing model class instead if rows map to models

Example fix

class MyRow extends \Phalcon\Mvc\Model\Row {} $query->setResultsetRowClass(MyRow::class);
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Query.zep:839 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/3f0a7ed1351f8448. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Query.zep:839

    {
        let this->type = type;

        return this;
    }

    /**
     * Sets the class used to hydrate rows that are not mapped to a model
     * (custom columns/joins). The class must be a subclass of
     * Phalcon\Mvc\Model\Row.
     */
    public function setResultsetRowClass(string resultsetRowClass) -> <QueryInterface>
    {
        if unlikely !class_exists(resultsetRowClass) {
            throw new ResultsetRowClassNotFound(resultsetRowClass);
        }

        if unlikely !is_subclass_of(resultsetRowClass, Row::class) {
            throw new InvalidResultsetRowClass(resultsetRowClass);
        }

        let this->resultsetRowClass = resultsetRowClass;

        return this;
    }

    /**
     * Tells to the query if only the first row in the resultset must be
     * returned
     */
    public function setUniqueRow(bool uniqueRow) -> <QueryInterface>
    {
        let this->uniqueRow = uniqueRow;

        return this;
    }

View on GitHub (pinned to b7419de9cd)