phalcon/cphalcon · error · JoinFieldCountMismatch

The number of fields must be equal to the number of referenc

Error message

The number of fields must be equal to the number of referenced fields in join {model}-{join}, when preparing: {phql}

What it means

Error "The number of fields must be equal to the number of referenced fields in join {model}-{join}, when preparing: {phql}" thrown in phalcon/cphalcon.

Source

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

        /**
         * Fields that join the 'from' model with the 'intermediate' model
         */
        let intermediateFields = relation->getIntermediateFields();

        /**
         * Fields that join the 'intermediate' model with the intermediate model
         */
        let intermediateReferencedFields = relation->getIntermediateReferencedFields();

        /**
         * Intermediate model
         */
        let referencedModelName = relation->getReferencedModel();

        if typeof fields == "array" {
            for field, position in fields {
                if unlikely !isset referencedFields[position] {
                    throw new JoinFieldCountMismatch(modelAlias, joinAlias, this->phql);
                }

                /**
                 * Get the referenced field in the same position
                 */
                let intermediateField = intermediateFields[position];

                /**
                 * Create a binary operation for the join conditions
                 */
                let sqlEqualsJoinCondition = [
                    "type" : "binary-op",
                    "op"   : "=",
                    "left" : this->getQualified(
                        [
                            "type"   : PHQL_T_QUALIFIED,
                            "domain" : modelAlias,
                            "name"   : field

View on GitHub (pinned to b7419de9cd)

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Query.zep:3019 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/9140dfd1a0cc1bf4. Report an issue: GitHub.