The only thing left to figure out was a way to maintain my records ordered after each order change. Here is a simple approach that worked for me:
First of all we will need a table column for storing the order, let’s name it sort_order.
avoid using ‘order’ as a table column since it is a MySQL reserved keyword!
From the client side we already have the ids of the rows dragged and replaced. So on the php action called upon ajax call we could do something like this:
*although there is some Yii-specific code here the logic can be applied regardless of the framework or language.