phalcon/cphalcon · error · Phalcon\Mvc\Model\Query\Exceptions\UpdateMultipleNotSupported

Updating several models at the same time is still not…

Error message

Updating several models at the same time is still not supported

What it means

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.

Solutions

  1. Update one model per PHQL UPDATE statement
  2. Loop over models inside a transaction, updating each separately
  3. Use raw SQL multi-table UPDATE via the db adapter if the DBMS supports it

Example fix

foreach ($models as $m) { $m->assign($data)->update(); } inside a transaction
Defensive patterns

Strategy: try-catch

Prevention

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Query.zep:1497 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/5c791f1be00807b0. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Query.zep:1497

            this->resultsetRowClass
        );
    }

    /**
     * Executes the UPDATE intermediate representation producing a
     * Phalcon\Mvc\Model\Query\Status
     */
    final protected function executeUpdate(array intermediate, array bindParams, array bindTypes) -> <StatusInterface>
    {
        var models, modelName, model, connection, dialect, fields, values,
            updateValues, fieldName, value, selectBindParams, selectBindTypes,
            number, field, records, exprValue, updateValue, wildcard, record,
            exception, sqlExpr, namedParams, paramKey, paramKeys, paramValue;

        let models = intermediate["models"];

        if unlikely isset models[1] {
            throw new UpdateMultipleNotSupported();
        }

        let modelName = models[0];

        /**
         * Load the model from the modelsManager or from the modelsInstances
         * property
         */
        if !fetch model, this->modelsInstances[modelName] {
            let model = this->manager->load(modelName);
        }

        let connection = this->getWriteConnection(
            model,
            intermediate,
            bindParams,
            bindTypes
        );

View on GitHub (pinned to b7419de9cd)