phalcon/cphalcon · error · MissingModelsManager
A models-manager is required to execute the query
Error message
A models-manager is required to execute the query
What it means
Generic guard in Query::prepareSelect: this->manager is not an object, i.e. the query was created without a models manager service, which is mandatory to resolve models. The input at fault is the DI container setup passed to the Query.
Solutions
- Inject the DI container so the query can resolve 'modelsManager': pass the container to Phalcon\Mvc\Model\Query or use DI-aware query creation.
- When instantiating Query manually, setModelsManager() with a ModelsManagerInterface.
- Verify 'modelsManager' is registered in the services list of your DI.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:3977 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/8dae0ea28d9e1a8c.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:3977
// Convert selected models in an array
if !isset tables[0] {
let selectedModels = [tables];
} else {
let selectedModels = tables;
}
// Convert selected columns in an array
if !isset columns[0] {
let selectColumns = [columns];
} else {
let selectColumns = columns;
}
let manager = this->manager,
metaData = this->metaData;
if unlikely typeof manager != "object" {
throw new MissingModelsManager();
}
if unlikely typeof metaData != "object" {
throw new MissingMetaData();
}
// Process selected models
let number = 0,
automaticJoins = [];
for selectedModel in selectedModels {
let qualifiedName = selectedModel["qualifiedName"],
modelName = qualifiedName["name"];
// Load a model instance from the models manager
let model = manager->load(modelName);
// Define a complete schema/sourceView on GitHub (pinned to b7419de9cd)