Custom update query in Yii Active Record

I want to use the following query afterSave function. How can I do it


set @i=0;update tbl_category set priority = @i:=@i+1 order by priority


	protected function  afterSave() {

		parent::afterSave();

		//update script which I want

	}

Please help me

Thank you

Usually you’d use DAO to issue complex SQL to your DB, but i’m not sure if it will support assignments (i.e. “set @i=0”):




$sql='set @i=0;update tbl_category set priority = @i:=@i+1 order by priority';

$this->dbConnection->createCommand($sql)->execute();

Thanks a lot. It works well. Also support assignments.