phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\InvalidReturnedRecord
The returned record is not valid
Error message
The returned record is not valid
What it means
Thrown in Resultset::delete while iterating: the current record lacks getWriteConnection(), meaning it is not a complete model object (e.g. a stdClass hydrated row), and resultset-wide deletion requires full model instances.
Solutions
- Execute the query with full object hydration (no columns()/groupBy that force stdClass rows).
- Delete records individually with checks, or issue a direct DELETE query instead.
- Use asArray(false)/default hydration so each element is a ModelInterface instance.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Resultset.zep:275 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/8846d5c298aacb64.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Resultset.zep:275
public function delete(<Closure> conditionCallback = null) -> bool
{
bool result, transaction;
var record, connection = null;
let result = true;
let transaction = false;
this->rewind();
while this->valid() {
let record = this->current();
if transaction === false {
/**
* We only can delete resultsets if every element is a complete object
*/
if unlikely !method_exists(record, "getWriteConnection") {
throw new InvalidReturnedRecord();
}
let connection = record->getWriteConnection(),
transaction = true;
connection->begin();
}
/**
* Perform additional validations
*/
if typeof conditionCallback == "object" {
if call_user_func_array(conditionCallback, [record]) === false {
this->next();
continue;
}
}View on GitHub (pinned to b7419de9cd)