{"record":{"id":"ae219d5b2e1b4ce2","repo":"phalcon/cphalcon","slug":"column-name-does-not-belong-to-any-of-the-sele","errorCode":null,"errorMessage":"Column '{name}' does not belong to any of the selected models ({tag}), when preparing: {phql}","messagePattern":"Column '(.+?)' does not belong to any of the selected models \\((.+?)\\), when preparing: (.+?)","errorType":"exception","errorClass":"ColumnNotInSelectedModels","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":3267,"sourceCode":"                 * Check if the attribute belongs to the current model\n                 */\n                if metaData->hasAttribute(model, columnName) {\n                    let number++;\n\n                    if unlikely number > 1 {\n                        throw new AmbiguousColumn(columnName, this->phql);\n                    }\n\n                    let hasModel = model;\n                }\n            }\n\n            /**\n             * After check in every model, the column does not belong to any of\n             * the selected models\n             */\n            if unlikely hasModel === false {\n                throw new ColumnNotInSelectedModels(columnName, \"1\", this->phql);\n            }\n\n            /**\n             * Check if the models property is correctly prepared\n             */\n            let models = this->models;\n\n            if unlikely typeof models != \"array\" {\n                throw new ModelsListNotLoaded();\n            }\n\n            /**\n             * Obtain the model's source from the models list\n             */\n            let className = get_class(hasModel);\n\n            if unlikely !fetch source, models[className] {\n                throw new ModelSourceNotFound(className, this->phql);","sourceCodeStart":3249,"sourceCodeEnd":3285,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L3249-L3285","documentation":"Thrown in Query::getQualified after scanning every model instance in the query: the column name matched no model attribute (hasModel === false), so the column cannot be resolved to any selected model's table. The tag is an internal trace code.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:3267 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the column name spelling against the model's attributes.","Join or select the model that actually owns this column.","With column renaming enabled, use the mapped property name rather than the database column name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}