{"record":{"id":"a221793c96404efd","repo":"phalcon/cphalcon","slug":"unknown-model-or-alias-model-tag-when-pre","errorCode":null,"errorMessage":"Unknown model or alias '{model}' ({tag}), when preparing: {phql}","messagePattern":"Unknown model or alias '(.+?)' \\((.+?)\\), when preparing: (.+?)","errorType":"exception","errorClass":"UnknownModelOrAlias","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":3207,"sourceCode":"            return [\n                \"type\": \"qualified\",\n                \"name\": columnName\n            ];\n        }\n\n        let metaData = this->metaData;\n\n        /**\n         * Check if the qualified name has a domain\n         */\n        if fetch columnDomain, expr[\"domain\"] {\n            let sqlAliases = this->sqlAliases;\n\n            /**\n             * The column has a domain, we need to check if it's an alias\n             */\n            if unlikely !fetch source, sqlAliases[columnDomain] {\n                throw new UnknownModelOrAlias(columnDomain, \"11\", this->phql);\n            }\n\n            /**\n             * Change the selected column by its real name on its mapped table\n             */\n            if Settings::get(\"orm.column_renaming\") {\n                /**\n                 * Retrieve the corresponding model by its alias\n                 */\n                let sqlAliasesModelsInstances = this->sqlAliasesModelsInstances;\n\n                /**\n                 * We need the model instance to retrieve the reversed column\n                 * map\n                 */\n                if unlikely !fetch model, sqlAliasesModelsInstances[columnDomain] {\n                    throw new NoModelForAlias(columnDomain, this->phql);\n                }","sourceCodeStart":3189,"sourceCodeEnd":3225,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L3189-L3225","documentation":"Thrown in Query::getQualified when a column expression carries a domain (table/alias prefix) that is not present in this->sqlAliases, i.e. the PHQL references a model name or alias that was never declared in FROM/JOIN for this query. The tag parameter is an internal trace code.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:3207 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the missing model to FROM/JOIN or fix the prefix spelling in the column reference.","Use the declared alias instead of the full model name (or vice versa) in column references.","When building PHQL programmatically, validate every domain against the registered aliases before execution."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}