{"record":{"id":"f1def237cbc6b5b0","repo":"phalcon/cphalcon","slug":"the-column-count-does-not-match-the-values-count","errorCode":null,"errorMessage":"The column count does not match the values count","messagePattern":"The column count does not match the values count","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Query\\Exceptions\\InsertColumnCountMismatch","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":1001,"sourceCode":"        if !fetch fields, intermediate[\"fields\"] {\n            let automaticFields = true,\n                fields = attributes;\n\n            if Settings::get(\"orm.column_renaming\") {\n                let columnMap = metaData->getColumnMap(model);\n            } else {\n                let columnMap = null;\n            }\n        }\n\n        let values = intermediate[\"values\"];\n\n        /**\n         * The number of calculated values must be equal to the number of fields\n         * in the model\n         */\n        if unlikely count(fields) != count(values) {\n            throw new InsertColumnCountMismatch();\n        }\n\n        /**\n         * Get the dialect to resolve the SQL expressions\n         */\n        let dialect = connection->getDialect();\n\n        let insertValues = [];\n        for number, value in values {\n            let exprValue = value[\"value\"];\n\n            switch value[\"type\"] {\n\n                case PHQL_T_STRING:\n                case PHQL_T_INTEGER:\n                case PHQL_T_DOUBLE:\n                    let insertValue = dialect->getSqlExpression(exprValue);\n                    break;","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L983-L1019","documentation":"Error \"The column count does not match the values count\" thrown in phalcon/cphalcon.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:1001 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}