{"record":{"id":"b64b6b915f7b3a57","repo":"phalcon/cphalcon","slug":"there-is-more-than-one-relation-between-models-f","errorCode":null,"errorMessage":"There is more than one relation between models '{from}' and '{join}', the join must be done using an alias, when preparing: {phql}","messagePattern":"There is more than one relation between models '(.+?)' and '(.+?)', the join must be done using an alias, when preparing: (.+?)","errorType":"exception","errorClass":"AmbiguousJoinRelation","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":2843,"sourceCode":"                        fromModelName,\n                        modelNameAlias\n                    );\n\n                    if relation === false {\n                        /**\n                         * Check for relations between models\n                         */\n                        let relations = manager->getRelationsBetween(\n                            fromModelName,\n                            modelNameAlias\n                        );\n\n                        if typeof relations == \"array\" {\n                            /**\n                             * More than one relation must throw an exception\n                             */\n                            if unlikely count(relations) != 1 {\n                                throw new AmbiguousJoinRelation(fromModelName, joinModel, this->phql);\n                            }\n\n                            /**\n                             * Get the first relationship\n                             */\n                            let relation = relations[0];\n                        }\n                    }\n\n                    /*\n                     * Valid relations are objects\n                     */\n                    if typeof relation == \"object\" {\n                        /**\n                         * Get the related model alias of the left part\n                         */\n                        let modelAlias = sqlModelsAliases[fromModelName];\n","sourceCodeStart":2825,"sourceCodeEnd":2861,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L2825-L2861","documentation":"Error \"There is more than one relation between models '{from}' and '{join}', the join must be done using an alias, when preparing: {phql}\" thrown in phalcon/cphalcon.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:2843 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"}