{"record":{"id":"b3e9e0392a618815","repo":"phalcon/cphalcon","slug":"cannot-obtain-the-model-s-source-from-the-models-l","errorCode":null,"errorMessage":"Cannot obtain the model's source from the models list: '{name}', when preparing: {phql}","messagePattern":"Cannot obtain the model's source from the models list: '(.+?)', when preparing: (.+?)","errorType":"exception","errorClass":"ModelSourceNotFound","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":3285,"sourceCode":"                throw new ColumnNotInSelectedModels(columnName, \"1\", this->phql);\n            }\n\n            /**\n             * Check if the models property is correctly prepared\n             */\n            let models = this->models;\n\n            if unlikely typeof models != \"array\" {\n                throw new ModelsListNotLoaded();\n            }\n\n            /**\n             * Obtain the model's source from the models list\n             */\n            let className = get_class(hasModel);\n\n            if unlikely !fetch source, models[className] {\n                throw new ModelSourceNotFound(className, this->phql);\n            }\n\n            /**\n             * Rename the column\n             */\n            if Settings::get(\"orm.column_renaming\") {\n                let columnMap = metaData->getReverseColumnMap(hasModel);\n            } else {\n                let columnMap = null;\n            }\n\n            if typeof columnMap == \"array\" {\n                /**\n                 * The real column name is in the column map\n                 */\n                if unlikely !fetch realColumnName, columnMap[columnName] {\n                    throw new ColumnNotInSelectedModels(columnName, \"3\", this->phql);\n                }","sourceCodeStart":3267,"sourceCodeEnd":3303,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L3267-L3303","documentation":"Thrown in Query::getQualified when the class name of the resolved model (get_class(hasModel)) has no entry in the prepared models list, so its table source cannot be obtained. This indicates the model was instantiated but never registered during query preparation.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:3285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the model is declared in FROM/JOIN of the same PHQL being executed.","Clear and rebuild query caches; check for class-name mismatches (namespace aliases).","Catch and log the class name plus PHQL to diagnose preparation order issues."],"exampleFix":null,"handlingStrategy":"try-catch","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"}