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

This type of statement generates multiple SQL statements

Error message

This type of statement generates multiple SQL statements

What it means

Query::executeGetRelatedMethods (multi-execution path) supports only PHQL_T_SELECT; any other statement type would run multiple times and produce multiple SQL statements, so MultipleSqlStatementsNotSupported is thrown. The faulty input is a non-SELECT query passed to an API meant for repeated SELECT execution.

Solutions

  1. Use execute() instead of the getRelated* / multi-execution path for INSERT/UPDATE/DELETE
  2. Restrict iteration helpers to SELECT queries
  3. Split compound statements into separate queries

Example fix

if ($query->getType() === PHQL_T_SELECT) { $rows = $query->execute(); }
Defensive patterns

Strategy: type-guard

Prevention

When it happens

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

Appendix: source

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

    {
        var intermediate;

        /**
         * The statement is parsed from its PHQL string or a previously
         * processed IR
         */
        let intermediate = this->parse();

        if this->type == PHQL_T_SELECT {
            return this->executeSelect(
                intermediate,
                this->bindParams,
                this->bindTypes,
                true
            );
        }

        throw new MultipleSqlStatementsNotSupported();
    }

    /**
     * @return TransactionInterface|null
     */
    public function getTransaction() -> <TransactionInterface> | null
    {
        return this->transaction;
    }

    /**
     * Gets the type of PHQL statement executed
     *
     * @return int
     */
    public function getType() -> int
    {
        return this->type;

View on GitHub (pinned to b7419de9cd)