yii 1.1.13, MS SQL Server 2012
CREATE TABLE [dbo].[name](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_name] PRIMARY KEY CLUSTERED
Model, contoller and CRUD created via gii.
_form.php:
$form=$this->beginWidget('CActiveForm', array('id'=>'name-form',));
echo $form->textField($model,'name',array('size'=>50,'maxlength'=>50));
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
$this->endWidget();
When
$model->attributes=$_POST['Name'];
$model->save();
General error: 20018 Cannot update identity column 'id'. [20018] (severity 5)
Temporary solution is:
unset($model->id)
, but it's not clear.
What solution is nice?