How To Re-Order Position Of Table Rows

Hello,

I’m developing a dynamic navbar menu from database based on Yiistrap TbNavbar.

How can I use Cdbcriiteria in my NavbarItems model to re-order the position of my navbaritems table?

I was thinking of to put the code in model method beforeSave(), but I do not know how to get it done.

If this is not the right place, please advise me what is…

I tried google, but did not find any solution with a re-order update criteria based on Cdbcriteria.

This is my table

ID tinyint(4) NOT NULL AUTO_INCREMENT,

label varchar(45) NOT NULL,

url varchar(255) NOT NULL,

visible tinyint(3) unsigned NOT NULL DEFAULT ‘0’,

status tinyint(1) unsigned NOT NULL DEFAULT ‘1’,

position tinyint(3) unsigned NOT NULL,

parentmenu tinyint(3) unsigned NOT NULL DEFAULT ‘0’,

PRIMARY KEY (ID)

In case of new record, when set position to the middle, let’s say position 6, all items upward 5 has to be updated +1.

In case of update record from position 6 to position 3, items upward 2 to 6 has to be updated +1

You may ignore above question, I have a solution.

there is nothing wrong with having it under beforeSave()