phalcon/cphalcon · error · MissingMetaData

Meta-data is required to execute the query

Error message

Meta-data is required to execute the query

What it means

Generic guard in Query::prepareSelect: this->metaData is not an object, i.e. no meta-data manager service is available to read model attribute/table information required to build the SQL. The input at fault is the DI container configuration.

Solutions

  1. Register 'modelsMetadata' in the DI and ensure the query container resolves it.
  2. When constructing Query manually, call setDI()/setMetaData with a MetaDataInterface.
  3. Check that a custom DI setup does not remove ORM services.
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

            let selectedModels = tables;
        }

        // Convert selected columns in an array
        if !isset columns[0] {
            let selectColumns = [columns];
        } else {
            let selectColumns = columns;
        }

        let manager = this->manager,
            metaData = this->metaData;

        if unlikely typeof manager != "object" {
            throw new MissingModelsManager();
        }

        if unlikely typeof metaData != "object" {
            throw new MissingMetaData();
        }

        // Process selected models
        let number = 0,
            automaticJoins = [];

        for selectedModel in selectedModels {
            let qualifiedName = selectedModel["qualifiedName"],
                modelName = qualifiedName["name"];

            // Load a model instance from the models manager
            let model = manager->load(modelName);

            // Define a complete schema/source
            let schema = model->getSchema(),
                source = model->getSource();

            // Obtain the real source including the schema

View on GitHub (pinned to b7419de9cd)