{"record":{"id":"00e9894422c55e9e","repo":"phalcon/cphalcon","slug":"number-of-referenced-fields-are-not-the-same-in-th-00e989","errorCode":null,"errorMessage":"Number of referenced fields are not the same in the HasMany relation of model '{entityName}' with Reference Model '{referencedEntity}'","messagePattern":"Number of referenced fields are not the same in the HasMany 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":413,"sourceCode":"            lowerAlias, singleRelations;\n        string keyRelation;\n\n        let entityName = get_class_lower(model),\n            referencedEntity = strtolower(referencedModel),\n            keyRelation = entityName . \"$\" . referencedEntity;\n\n        let hasMany = this->hasMany;\n\n        if !fetch relations, hasMany[keyRelation] {\n            let relations = [];\n        }\n\n        /**\n         * Check if the number of fields are the same\n         */\n        if typeof referencedFields == \"array\" {\n            if unlikely count(fields) != count(referencedFields) {\n                throw new ReferencedFieldsMismatch(\"HasMany\", entityName, referencedEntity);\n            }\n        }\n\n        /**\n         * Create a relationship instance\n         */\n        let relation = new Relation(\n            Relation::HAS_MANY,\n            referencedModel,\n            fields,\n            referencedFields,\n            options\n        );\n\n        /**\n         * Check an alias for the relation\n         */\n        if fetch alias, options[\"alias\"] {","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Manager.zep#L395-L431","documentation":"Error \"Number of referenced fields are not the same in the HasMany relation of model '{entityName}' with Reference Model '{referencedEntity}'\" thrown in phalcon/cphalcon.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Manager.zep:413 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"}