The following code will do what you want.
$item = $this->Country->findBySlug($slug);
$item['Country']['booleanField'] = ($item['Country']['booleanField']
== 0)?1:0;
$this->Country->save($item, true, array('booleanField'));
Cheers,
Ketan :-)
On Jun 18, 1:15 pm, BoSc <[EMAIL PROTECTED]> 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);
>
> to access the data, but this leaves me with an array instead of an
> object.
>
> Is there any other way to instantiate a object with a similar function
> like findbyslug which allows me to make changes in the data
> $this->Country->boolean = 0, and then $this->Country->save(), to execute the
>
> changes?
>
> thanks
>
> ps. as you might have noticed I'm pretty new to CakePHP, but I'm
> trying to make the swicth.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---