phalcon/cphalcon · error · AmbiguousColumn

The column '{name}' is ambiguous, when preparing: {phql}

Error message

The column '{name}' is ambiguous, when preparing: {phql}

What it means

Error "The column '{name}' is ambiguous, when preparing: {phql}" thrown in phalcon/cphalcon.

Source

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

                let realColumnName = columnName;
            }
        } else {
            /**
             * If the column IR does not have a domain, we must check for
             * ambiguities
             */
            let number = 0,
                hasModel = false;

            for model in this->modelsInstances {
                /**
                 * Check if the attribute belongs to the current model
                 */
                if metaData->hasAttribute(model, columnName) {
                    let number++;

                    if unlikely number > 1 {
                        throw new AmbiguousColumn(columnName, this->phql);
                    }

                    let hasModel = model;
                }
            }

            /**
             * After check in every model, the column does not belong to any of
             * the selected models
             */
            if unlikely hasModel === false {
                throw new ColumnNotInSelectedModels(columnName, "1", this->phql);
            }

            /**
             * Check if the models property is correctly prepared
             */
            let models = this->models;

View on GitHub (pinned to b7419de9cd)

When it happens

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