{"record":{"id":"9140dfd1a0cc1bf4","repo":"phalcon/cphalcon","slug":"the-number-of-fields-must-be-equal-to-the-number-o","errorCode":null,"errorMessage":"The number of fields must be equal to the number of referenced fields in join {model}-{join}, when preparing: {phql}","messagePattern":"The number of fields must be equal to the number of referenced fields in join (.+?)-(.+?), when preparing: (.+?)","errorType":"exception","errorClass":"JoinFieldCountMismatch","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":3019,"sourceCode":"        /**\n         * Fields that join the 'from' model with the 'intermediate' model\n         */\n        let intermediateFields = relation->getIntermediateFields();\n\n        /**\n         * Fields that join the 'intermediate' model with the intermediate model\n         */\n        let intermediateReferencedFields = relation->getIntermediateReferencedFields();\n\n        /**\n         * Intermediate model\n         */\n        let referencedModelName = relation->getReferencedModel();\n\n        if typeof fields == \"array\" {\n            for field, position in fields {\n                if unlikely !isset referencedFields[position] {\n                    throw new JoinFieldCountMismatch(modelAlias, joinAlias, this->phql);\n                }\n\n                /**\n                 * Get the referenced field in the same position\n                 */\n                let intermediateField = intermediateFields[position];\n\n                /**\n                 * Create a binary operation for the join conditions\n                 */\n                let sqlEqualsJoinCondition = [\n                    \"type\" : \"binary-op\",\n                    \"op\"   : \"=\",\n                    \"left\" : this->getQualified(\n                        [\n                            \"type\"   : PHQL_T_QUALIFIED,\n                            \"domain\" : modelAlias,\n                            \"name\"   : field","sourceCodeStart":3001,"sourceCodeEnd":3037,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L3001-L3037","documentation":"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.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:3019 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":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}