phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\InvalidModelName
Model name must be string
Error message
Model name must be string
What it means
Thrown by Model Criteria::execute when the criteria's model name is not a string, so {model}::find() cannot be invoked. Set the criteria's model with a valid model class name (setModelName) before executing.
Solutions
- Call setModelName('YourModel') on the Criteria before execute()
- Build the Criteria via the model's query() or a ModelManager helper so the model name is always set
- Ensure the model name variable passed to setModelName() is not null or an object
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Criteria.zep:308 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/b9eeb494612c2149.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Criteria.zep:308
*/
public function eager(array paths) -> <Criteria>
{
let this->params["eager"] = paths;
return this;
}
/**
* Executes a find using the parameters built with the criteria
*/
public function execute() -> <ResultsetInterface>
{
var model;
let model = this->getModelName();
if unlikely typeof model != "string" {
throw new InvalidModelName();
}
return {model}::find(
this->getParams()
);
}
/**
* Adds the "for_update" parameter to the criteria
*/
public function forUpdate(bool forUpdate = true) -> <CriteriaInterface>
{
let this->params["for_update"] = forUpdate;
return this;
}
/**View on GitHub (pinned to b7419de9cd)