Well, that's true but my assumption was to save record with position number the same as ID. That would protect me before doubling values. So in case I have unique values - why it doesn't work?
I also tried saveField but it behaves strangely - sometimes it works sometimes doesn't ... On Jul 21, 6:53 pm, brian <bally.z...@gmail.com> wrote: > This is unlikely to work the way that you want. The problem is that > you change one record's position to, eg. 23 but there may be another > record that already has that value. In order for this to work, you'll > have to re-sort the entire table. > > You might want to use TreeBehavior to take advantage of its moveup() & > movedown() methods. You can do this even if your records are all on > the same level, hierarchically. > > 2009/7/21 mariusz.lewandowski <lew...@gmail.com>: > > > > > Hello all! > > > I'm trying to implement functionality in my CMS system to be able to > > move up/down items on the list based on "position" column. > > > Here is my code: > > > public function admin_up($position) { > > > $neighbours = $this->News->find('neighbors', > > array('position' => > > $position)); > > $currentRecord = $this->News->findByPosition($position); > > > $currentRecord = $currentRecord['News']; > > $previousRecord = $neighbours['prev']['News']; > > > $this->temp = $previousRecord; > > > $this->News->id = $previousRecord['id']; > > $this->News->position = $currentRecord['position']; > > $this->News->save(); > > > $this->News->id = $currentRecord['id']; > > $this->News->position = $this->temp['position']; > > $this->News->save(); > > > // $this->Session->setFlash("News został przesunięty!"); > > // $this->redirect('index'); > > } > > > and SQL dump: > > > UPDATE `news` SET `id` = 20, `position` = 23 WHERE `news`.`id` = 20 > > UPDATE `news` SET `id` = 20, `position` = 23 WHERE `news`.`id` = 20 > > > it invokes bad parametrs in second call. Why? I spent for it 10 hours > > and still the same results... > > > Please help, I'm getting confused! :S --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---