How to update field value increament by 1 with AR?


I would like to do and update table field data increment by one when this controller process was trigger. Any one can tell me how to write it in Active Record? i know SQL can do like this

$orders_status_sql = "	UPDATE ".Yii::app()->params['TABLE_ORDERS_STATUS_STAT']." SET occurrence=occurrence+".(int)$increment.", latest_date = ".$o_latest_date.",changed_by = '".$record_array['changed_by']."'WHERE orders_id = ".$o_id." AND orders_status_id = ".$o_status_id;

Your way is not good approach, this is what u need

Any other method to write in Active record form?

You can define a beforeSave function in in model to do this task.with the help of some conditional statements.