Thanks, works like a charm. The problem was I didn't know how to create a reference to a certain row, so this line helped me crack it: $this->Country->id = $item['Country']['id'];
Thanks. On Jun 18, 7:23 pm, "John David Anderson (_psychic_)" <[EMAIL PROTECTED]> wrote: > On Jun 18, 2007, at 11:15 AM, BoSc wrote: > > > > > Hi, > > > I want to use a update function in my controller that flips a boolean > > field only. > > > I call the page withhttp://website/mode/flip/slug > > > When this function is called, it should check whether the database > > entry for "slug" in "model" contains a 0 or a 1, additionaly it should > > write the opposite value back. How should I accomplish this? > > > i used > > > $item = $this->Country->findBySlug($slug); > > $this->Country->id = $item['Country']['id']; > > if($item['Country']['nameofbooleanfield']) > { > $this->Country->saveField('nameofbooleanfield', 0);} > > else > { > $this->Country->saveField('nameofbooleanfield', 1); > > } > > You'd want to throw in some error checking (to make sure the Country > with the slug is found, etc.), but this is one way you could do it. > > -- John --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
