{"record":{"id":"76d73c62f2e517ed","repo":"phalcon/cphalcon","slug":"the-model-model-does-not-have-the-attribute","errorCode":null,"errorMessage":"The model '{model}' does not have the attribute '{attribute}', when preparing: {phql}","messagePattern":"The model '(.+?)' does not have the attribute '(.+?)', when preparing: (.+?)","errorType":"exception","errorClass":"MissingModelAttribute","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":3865,"sourceCode":"            ];\n        }\n\n        let sqlInsert = [\n            \"model\": modelName,\n            \"table\": source\n        ];\n\n        let metaData = this->metaData;\n\n        if fetch fields, ast[\"fields\"] {\n            let sqlFields = [];\n\n            for field in fields {\n                let name = field[\"name\"];\n\n                // Check that inserted fields are part of the model\n                if unlikely !metaData->hasAttribute(model, name) {\n                    throw new MissingModelAttribute(modelName, name, this->phql);\n                }\n\n                // Add the file to the insert list\n                let sqlFields[] = name;\n            }\n\n            let sqlInsert[\"fields\"] = sqlFields;\n        }\n\n        let sqlInsert[\"values\"] = exprValues;\n\n        return sqlInsert;\n    }\n\n    /**\n     * Analyzes a SELECT intermediate code and produces an array to be executed later\n     */\n    final protected function prepareSelect(var ast = null, bool merge = false) -> array","sourceCodeStart":3847,"sourceCodeEnd":3883,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L3847-L3883","documentation":"Thrown in Query::prepareInsert while validating the explicit field list: a field named in INSERT INTO Model (fields) is not an attribute of the target model per its metadata, so the insert would target a nonexistent column. The input at fault is the field name in the PHQL.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:3865 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use model attribute (property) names, not raw database column names, in the INSERT field list.","Refresh model metadata caches if the model recently gained the attribute.","Remove the unknown field or add it to the model."],"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"}