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

Unknown statement

Error message

Unknown statement {type}

What it means

Query::execute()'s switch over the parsed statement type reached the default branch, meaning the PHQL statement type produced by the parser is not SELECT/INSERT/UPDATE/DELETE; UnknownPhqlStatement is thrown. The faulty input is an unsupported or unrecognized statement type in the parsed PHQL IR.

Solutions

  1. Execute only supported PHQL statements (SELECT/INSERT/UPDATE/DELETE)
  2. Check for corrupted or hand-modified intermediate representation passed to parse()/execute()
  3. Report unexpected types for valid statements to the framework maintainers

Example fix

if (in_array($queryType, [PHQL_T_SELECT, PHQL_T_INSERT, PHQL_T_UPDATE, PHQL_T_DELETE])) { $query->execute(); }
Defensive patterns

Strategy: validation

Prevention

When it happens

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

Appendix: source

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

                let result = this->executeUpdate(
                    intermediate,
                    mergedParams,
                    mergedTypes
                );

                break;

            case PHQL_T_DELETE:
                let result = this->executeDelete(
                    intermediate,
                    mergedParams,
                    mergedTypes
                );

                break;

            default:
                throw new UnknownPhqlStatement(type);
        }

        /**
         * We store the resultset in the cache if any
         */
        if cacheOptions !== null {
            /**
             * Only PHQL SELECTs can be cached
             */
            if type != PHQL_T_SELECT {
                throw new ResultsetNonCacheable();
            }

            cache->set(key, result, lifetime);
        }

        /**
         * Check if only the first row must be returned

View on GitHub (pinned to b7419de9cd)