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

Cannot obtain table columns for the mapped source

Error message

Cannot obtain table columns for the mapped source '{completeTable}' used in model {className}

What it means

After confirming the table exists, Introspection calls readConnection->describeColumns(); if that returns an empty column list the table's structure cannot be introspected and CannotObtainTableColumns is thrown. Indicates a driver/permission problem or a table with no columns rather than a missing table.

Solutions

  1. Check the DB user has privileges to run DESCRIBE/SHOW COLUMNS on the table
  2. Verify the adapter supports describeColumns for the target DBMS
  3. Confirm the table actually has columns (corrupt schema)

Example fix

try { $meta = $metaData->readMetaData($model); } catch (CannotObtainTableColumns $e) { /* check DB grants/driver */ }
Defensive patterns

Strategy: try-catch

Prevention

When it happens

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

Appendix: source

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

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

        /**
         * Initialize meta-data
         */
        let attributes = [];
        let primaryKeys = [];
        let nonPrimaryKeys = [];
        let numericTyped = [];
        let notNull = [];
        let fieldTypes = [];
        let fieldBindTypes = [];
        let automaticDefault = [];
        let identityField = false;
        let defaultValues = [];
        let emptyStringValues = [];

        for column in columns {

View on GitHub (pinned to b7419de9cd)