phalcon/cphalcon · error · ColumnNotInDomain
Column ' ' does not belong to the model or alias ' ', when…
Error message
Column '{name}' does not belong to the model or alias '{model}', when executing: {phql} What it means
Thrown in Query::getQualified when column renaming is enabled and the referenced column name is not found in the model's reversed column map, i.e. the PHQL uses a column name that does not exist on the aliased model. The input at fault is the column name plus its model/alias domain.
Solutions
- Use the model property name as defined in the model class / column map, not the raw database column name.
- Verify metaData->getReverseColumnMap contains the column; refresh metadata caches if the schema changed.
- Qualify the column with the correct alias if it belongs to a different model in the query.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:3234 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/dfdb99986629c3c9.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:3234
*/
let sqlAliasesModelsInstances = this->sqlAliasesModelsInstances;
/**
* We need the model instance to retrieve the reversed column
* map
*/
if unlikely !fetch model, sqlAliasesModelsInstances[columnDomain] {
throw new NoModelForAlias(columnDomain, this->phql);
}
let columnMap = metaData->getReverseColumnMap(model);
} else {
let columnMap = null;
}
if typeof columnMap == "array" {
if unlikely !fetch realColumnName, columnMap[columnName] {
throw new ColumnNotInDomain(columnName, columnDomain, this->phql);
}
} else {
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++;View on GitHub (pinned to b7419de9cd)