phalcon/cphalcon · error · ModelSourceNotFound
Cannot obtain the model's source from the models list
Error message
Cannot obtain the model's source from the models list: '{name}', when preparing: {phql} What it means
Thrown in Query::getQualified when the class name of the resolved model (get_class(hasModel)) has no entry in the prepared models list, so its table source cannot be obtained. This indicates the model was instantiated but never registered during query preparation.
Solutions
- Ensure the model is declared in FROM/JOIN of the same PHQL being executed.
- Clear and rebuild query caches; check for class-name mismatches (namespace aliases).
- Catch and log the class name plus PHQL to diagnose preparation order issues.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:3285 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/b3e9e0392a618815.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:3285
throw new ColumnNotInSelectedModels(columnName, "1", this->phql);
}
/**
* Check if the models property is correctly prepared
*/
let models = this->models;
if unlikely typeof models != "array" {
throw new ModelsListNotLoaded();
}
/**
* Obtain the model's source from the models list
*/
let className = get_class(hasModel);
if unlikely !fetch source, models[className] {
throw new ModelSourceNotFound(className, this->phql);
}
/**
* Rename the column
*/
if Settings::get("orm.column_renaming") {
let columnMap = metaData->getReverseColumnMap(hasModel);
} else {
let columnMap = null;
}
if typeof columnMap == "array" {
/**
* The real column name is in the column map
*/
if unlikely !fetch realColumnName, columnMap[columnName] {
throw new ColumnNotInSelectedModels(columnName, "3", this->phql);
}View on GitHub (pinned to b7419de9cd)