phalcon/cphalcon · error · Phalcon\Mvc\Model\MetaData\Exceptions\TableNotInDatabase

Table ' ' does not exist in database when dumping meta-data…

Error message

Table '{completeTable}' does not exist in database when dumping meta-data for {className}

What it means

Introspection::getMetaData() checks readConnection->tableExists() before describing the model's table; when the mapped source/schema does not exist in the database it throws TableNotInDatabase. Usually caused by a wrong getSource()/getSchema(), a missing migration, or connecting to the wrong database.

Solutions

  1. Run database migrations to create the missing table
  2. Correct the model's getSource()/getSchema() return values
  3. Verify the DI 'db' service points to the intended database

Example fix

try { $metadata = $metaData->getMetaData($model); } catch (TableNotInDatabase $e) { /* run migrations or log misconfiguration */ }
Defensive patterns

Strategy: try-catch

Prevention

When it happens

Trigger: Thrown at phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep:89 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/027a943b2d18983b. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep:89

        let schema = model->getSchema(),
            table  = model->getSource();

        /**
         * Check if the mapped table exists on the database
         */
        let readConnection = model->getReadConnection();

        if unlikely !readConnection->tableExists(table, schema) {
            if schema {
                let completeTable = schema . "'.'" . table;
            } else {
                let completeTable = table;
            }

            /**
             * The table not exists
             */
            throw new TableNotInDatabase(completeTable, get_class(model));
        }

        /**
         * Try to describe the table
         */
        let columns = readConnection->describeColumns(table, schema);

        if unlikely empty columns {
            if schema {
                let completeTable = schema . "'.'" . table;
            } else {
                let completeTable = table;
            }

            /**
             * The table not exists
             */
            throw new CannotObtainTableColumns(completeTable, get_class(model));

View on GitHub (pinned to b7419de9cd)