insert default value 0

Hey Guys,

I have configured my database "Default value 0", but when I insert then it is NULL.

if user don’t pick any value from dropdown then should be insert 0 not “NULL”. Can you help me?


		&#036;criteria = new CDbCriteria;

		&#036;criteria-&gt;order = 'name'; //or whatever field

		echo CHtml::activeDropDownList(&#036;form,'id',CHtml::listData(address::model()-&gt;findAll(&#036;criteria),'id','name'), array('prompt'=&gt; 'Please select name'));



I don’t know why you have this issue.

Try setting in database NOT NULL default 0.

If this still doesn’t work, you can fix by implementing BeforeSave in the model:

protected function BeforeSave()


   if (!$this->id)// or ($this->id===null)


   return parent::beforeSave();