{"record":{"id":"7ea96f339bc056aa","repo":"phalcon/cphalcon","slug":"number-of-referenced-fields-are-not-the-same-in-th-7ea96f","errorCode":null,"errorMessage":"Number of referenced fields are not the same in the HasManytoMany relation of model '{entityName}' with Reference Model '{referencedEntity}'","messagePattern":"Number of referenced fields are not the same in the HasManytoMany relation of model '(.+?)' with Reference Model '(.+?)'","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Exceptions\\ReferencedFieldsMismatch","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Manager.zep","lineNumber":515,"sourceCode":"\n        let entityName = get_class_lower(model),\n            intermediateEntity = strtolower(intermediateModel),\n            referencedEntity = strtolower(referencedModel),\n            keyRelation = entityName . \"$\" . referencedEntity;\n\n        let hasManyToMany = this->hasManyToMany;\n\n        if !fetch relations, hasManyToMany[keyRelation] {\n            let relations = [];\n        }\n\n        /**\n         * Check if the number of fields are the same from the model to the\n         * intermediate model\n         */\n        if typeof intermediateFields == \"array\" {\n            if unlikely count(fields) != count(intermediateFields) {\n                throw new ReferencedFieldsMismatch(\"HasManytoMany\", entityName, referencedEntity);\n            }\n        }\n\n        /**\n         * Check if the number of fields are the same from the intermediate\n         * model to the referenced model\n         */\n        if typeof intermediateReferencedFields == \"array\" {\n            if unlikely count(fields) != count(intermediateFields) {\n                throw new ReferencedFieldsMismatch(\"HasManytoMany\", entityName, referencedEntity);\n            }\n        }\n\n        /**\n         * Create a relationship instance\n         */\n        let relation = new Relation(\n            Relation::HAS_MANY_THROUGH,","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Manager.zep#L497-L533","documentation":"Error \"Number of referenced fields are not the same in the HasManytoMany relation of model '{entityName}' with Reference Model '{referencedEntity}'\" thrown in phalcon/cphalcon.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Manager.zep:515 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"}