Increasing amodel attribute and then saving it.

I want to increase a model attribute value by 1. The attribute value is int in database





$aaa=$model->aaa;

		  	$model->aaa =$aaa - 1 ;  or to increase I will use 	$model->aaa =$aaa + 1 ;

$model->save();




It is not working.

Can I know what is wrong?

You want to increase (+1) but your code is ($aaa-1). Is this wrong?

Sorry about that I want to increase and decrease certain parts, I thought if I can find the increase one I can do the descrease one also?

Would updateCounters() help?

http://www.yiiframework.com/doc/api/1.1/CActiveRecord#updateCounters-detail

How will I decrease here?

The documentation is very clear…

To decrease:


$model->updateCounters(array('aaa' => -1), '<yourcondition>');