phalcon/cphalcon · error · AmbiguousJoinRelation

There is more than one relation between models '{from}' and

Error message

There is more than one relation between models '{from}' and '{join}', the join must be done using an alias, when preparing: {phql}

What it means

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.

Source

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

                        fromModelName,
                        modelNameAlias
                    );

                    if relation === false {
                        /**
                         * Check for relations between models
                         */
                        let relations = manager->getRelationsBetween(
                            fromModelName,
                            modelNameAlias
                        );

                        if typeof relations == "array" {
                            /**
                             * More than one relation must throw an exception
                             */
                            if unlikely count(relations) != 1 {
                                throw new AmbiguousJoinRelation(fromModelName, joinModel, this->phql);
                            }

                            /**
                             * Get the first relationship
                             */
                            let relation = relations[0];
                        }
                    }

                    /*
                     * Valid relations are objects
                     */
                    if typeof relation == "object" {
                        /**
                         * Get the related model alias of the left part
                         */
                        let modelAlias = sqlModelsAliases[fromModelName];

View on GitHub (pinned to b7419de9cd)

When it happens

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