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

Delete from several models at the same time is still not…

Error message

Delete from several models at the same time is still not supported

What it means

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.

Solutions

  1. Rewrite as a single-model DELETE with a WHERE/IN subquery on the other model
  2. Delete records per model in a loop or transaction
  3. Use a raw SQL multi-table delete through the db service if the DBMS supports it

Example fix

DELETE FROM Robots WHERE Robots.id IN (SELECT r.id FROM Robots r JOIN Parts p ON ...)
Defensive patterns

Strategy: try-catch

Prevention

When it happens

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

Appendix: source

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

    public function setUniqueRow(bool uniqueRow) -> <QueryInterface>
    {
        let this->uniqueRow = uniqueRow;

        return this;
    }

    /**
     * Executes the DELETE intermediate representation producing a
     * Phalcon\Mvc\Model\Query\Status
     */
    final protected function executeDelete(array intermediate, array bindParams, array bindTypes) -> <StatusInterface>
    {
        var models, modelName, model, records, connection, record, exception;

        let models = intermediate["models"];

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

        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);
        }

        /**
         * Get the records to be deleted
         */
        let records = this->getRelatedRecords(
            model,
            intermediate,
            bindParams,

View on GitHub (pinned to b7419de9cd)