
December 6th, 2012, 10:45 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
Quote: | Originally Posted by andrelic ... or if it would have to be done in php code. | yes, the latter
and it's quite ugly, and the processing hit on your table is excessive -- you end up updating the entire table if you wanted to move something to priority 1 (which happens often, right?)
i've seen this problem done with floating point numbers, though, which is really neat, because if you have to move an item, you simply update its number to the average number in between the two numbers that you want the moved item to end up between, and you can keep doing this thousands and millions of times, because they're floating point numbers
of course, when you display them, you number them consecutively starting at 1, but they keep their floating point number under the covers
this way, you only ever update the item that's moving
|