phalcon/cphalcon · error · JoinAliasAlreadyUsed

Cannot use '{alias}' as join alias because it was already us

Error message

Cannot use '{alias}' as join alias because it was already used, when preparing: {phql}

What it means

Error "Cannot use '{alias}' as join alias because it was already used, when preparing: {phql}" thrown in phalcon/cphalcon.

Source

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

                realModelName = joinData["modelName"],
                completeSource = [source, schema];

            /**
             * Check join alias
             */
            let joinType = this->getJoinType(joinItem);

            /**
             * Process join alias
             */
            if fetch aliasExpr, joinItem["alias"] {
                let alias = aliasExpr["name"];

                /**
                 * Check if alias is unique
                 */
                if unlikely isset joinModels[alias] {
                    throw new JoinAliasAlreadyUsed(alias, this->phql);
                }

                /**
                 * Add the alias to the source
                 */
                let completeSource[] = alias;

                /**
                 * Set the join type
                 */
                let joinTypes[alias] = joinType;

                /**
                 * Update alias: alias
                 */
                let sqlAliases[alias] = alias;

                /**

View on GitHub (pinned to b7419de9cd)

When it happens

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