chennaiiq
(Chennaiiq)
1
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
mikl
(Mike)
2
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();
chennaiiq
(Chennaiiq)
3
Thanks a lot. It works well. Also support assignments.