尝试更新表中的记录时遇到以下错误:
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ABCD1111P' for key 'pan_UNIQUE'
表有列,即“pan”,它分配了唯一的键。
以下是我在控制器中的代码:
$model->pan = $_POST['CustomerBasics']['pan'];
$model->cell = $_POST['CustomerBasics']['cell'];
$model->gender = $_POST['PersonalDetails']['gender'];
$valid = $model->validate();
print_r($model->getErrors());
if ($valid) {
$model->update();
$personal_details_id = $model->personal_details_id;
}
在模型中:
array('pan', 'unique', 'on' => 'insert', 'message' => '{attribute}:{value} already exists!'),
问题是什么?我哪里错了?
谢谢。