{"record":{"id":"8846d5c298aacb64","repo":"phalcon/cphalcon","slug":"the-returned-record-is-not-valid","errorCode":null,"errorMessage":"The returned record is not valid","messagePattern":"The returned record is not valid","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Exceptions\\InvalidReturnedRecord","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Resultset.zep","lineNumber":275,"sourceCode":"    public function delete(<Closure> conditionCallback = null) -> bool\n    {\n        bool result, transaction;\n        var record, connection = null;\n\n        let result = true;\n        let transaction = false;\n\n        this->rewind();\n\n        while this->valid() {\n            let record = this->current();\n\n            if transaction === false {\n                /**\n                 * We only can delete resultsets if every element is a complete object\n                 */\n                if unlikely !method_exists(record, \"getWriteConnection\") {\n                    throw new InvalidReturnedRecord();\n                }\n\n                let connection = record->getWriteConnection(),\n                    transaction = true;\n\n                connection->begin();\n            }\n\n            /**\n             * Perform additional validations\n             */\n            if typeof conditionCallback == \"object\" {\n                if call_user_func_array(conditionCallback, [record]) === false {\n                    this->next();\n\n                    continue;\n                }\n            }","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Resultset.zep#L257-L293","documentation":"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.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Resultset.zep:275 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}