{"record":{"id":"5c791f1be00807b0","repo":"phalcon/cphalcon","slug":"updating-several-models-at-the-same-time-is-still","errorCode":null,"errorMessage":"Updating several models at the same time is still not supported","messagePattern":"Updating several models at the same time is still not supported","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Query\\Exceptions\\UpdateMultipleNotSupported","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":1497,"sourceCode":"            this->resultsetRowClass\n        );\n    }\n\n    /**\n     * Executes the UPDATE intermediate representation producing a\n     * Phalcon\\Mvc\\Model\\Query\\Status\n     */\n    final protected function executeUpdate(array intermediate, array bindParams, array bindTypes) -> <StatusInterface>\n    {\n        var models, modelName, model, connection, dialect, fields, values,\n            updateValues, fieldName, value, selectBindParams, selectBindTypes,\n            number, field, records, exprValue, updateValue, wildcard, record,\n            exception, sqlExpr, namedParams, paramKey, paramKeys, paramValue;\n\n        let models = intermediate[\"models\"];\n\n        if unlikely isset models[1] {\n            throw new UpdateMultipleNotSupported();\n        }\n\n        let modelName = models[0];\n\n        /**\n         * Load the model from the modelsManager or from the modelsInstances\n         * property\n         */\n        if !fetch model, this->modelsInstances[modelName] {\n            let model = this->manager->load(modelName);\n        }\n\n        let connection = this->getWriteConnection(\n            model,\n            intermediate,\n            bindParams,\n            bindTypes\n        );","sourceCodeStart":1479,"sourceCodeEnd":1515,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L1479-L1515","documentation":"Query::executeUpdate() checks intermediate['models']; an UPDATE that targets or joins multiple models is unsupported and UpdateMultipleNotSupported is thrown. The faulty input is a PHQL UPDATE statement affecting several models in one statement.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:1497 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Update one model per PHQL UPDATE statement","Loop over models inside a transaction, updating each separately","Use raw SQL multi-table UPDATE via the db adapter if the DBMS supports it"],"exampleFix":"foreach ($models as $m) { $m->assign($data)->update(); } inside a transaction","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep UPDATE statements single-model","Cover update flows with tests that assert one model per query"],"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"}