{"record":{"id":"b8f991e7cbc3ccf0","repo":"phalcon/cphalcon","slug":"delete-from-several-models-at-the-same-time-is-sti","errorCode":null,"errorMessage":"Delete from several models at the same time is still not supported","messagePattern":"Delete from several models at the same time is still not supported","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Query\\Exceptions\\DeleteMultipleNotSupported","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":869,"sourceCode":"    public function setUniqueRow(bool uniqueRow) -> <QueryInterface>\n    {\n        let this->uniqueRow = uniqueRow;\n\n        return this;\n    }\n\n    /**\n     * Executes the DELETE intermediate representation producing a\n     * Phalcon\\Mvc\\Model\\Query\\Status\n     */\n    final protected function executeDelete(array intermediate, array bindParams, array bindTypes) -> <StatusInterface>\n    {\n        var models, modelName, model, records, connection, record, exception;\n\n        let models = intermediate[\"models\"];\n\n        if unlikely isset models[1] {\n            throw new DeleteMultipleNotSupported();\n        }\n\n        let modelName = models[0];\n\n        /**\n         * Load the model from the modelsManager or from the modelsInstances property\n         */\n        if !fetch model, this->modelsInstances[modelName] {\n            let model = this->manager->load(modelName);\n        }\n\n        /**\n         * Get the records to be deleted\n         */\n        let records = this->getRelatedRecords(\n            model,\n            intermediate,\n            bindParams,","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L851-L887","documentation":"Query::executeDelete() inspects intermediate['models']; a DELETE that joins or targets more than one model (models[1] set) is unsupported, so DeleteMultipleNotSupported is thrown. The faulty input is a PHQL DELETE referencing multiple models, e.g. with a JOIN.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:869 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rewrite as a single-model DELETE with a WHERE/IN subquery on the other model","Delete records per model in a loop or transaction","Use a raw SQL multi-table delete through the db service if the DBMS supports it"],"exampleFix":"DELETE FROM Robots WHERE Robots.id IN (SELECT r.id FROM Robots r JOIN Parts p ON ...)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep PHQL DELETE statements limited to one model","Test delete operations covering relationships before release"],"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"}