使用Yii中的updateAll方法通过某个数字更新字段值

I am a beginner in Yii framework. I have got a situation where i need to do like this

I have a column rgt in database and i want to increment that by 2 in some conditions.

I have written like these

Category::model()->updateAll( array("rgt"=>"rgt+2"),array("condition"=>"rgt >".$this->myRight));

this is not working. I am not sure what i wrote is right. Please help me

Thanks in advance

You can't pass DB expressions like rgt+2 to updateAll(). It will try to set this as column value and probably fail, as the column is of type INT. But you could use updateCounters() instead:

Category::model()->updateCounters(array(
    'rgt' => 2,
), 'rgt > '.$this->myRight);