If you are staying on MySQL you can do something like: SET @pos=0; UPDATE busstops SET pos = ( SELECT @pos := @pos +1 ) WHERE route = 1 ORDER BY pos ASC
Found that on: http://dev.mysql.com/doc/refman/5.0/en/update.html Roughly half-way down the comments. Search for: Posted by Christian Hansel on July 1 2005 9:13am and you should find the explanations to go with the code. good luck On Oct 6, 10:16 am, WebbedIT <p...@webbedit.co.uk> wrote: > You are right I am trying to achieve the simple task of resetting the > ordering each time to 1, 2, 3, 4, 5 etc. > > If there is a more efficient way to do it then I would love to > implement it. I must confess I am no MySQL expert, but I have done > various searches to find a single SQL query that would do the job and > came up short. > > Strange thing is though, the afterSave works fine if you are not > uploading a new image ... and uploading an image should have no baring > on resetting the number values of the records. > > I have created a workaround for this though by creating my own model > action which I manually call after a create/edit/delete which in > effect is doing exactly the same as the above, just called differently. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---