Thanks for your reply.

The action is simple. In my index action, there is a list of all  
Musician Requests. After every Request, there is a link, which  
executes my extend action with the given ID.
The Extend Action shoul only take 'lifetime' and adding 4 weeks to  
it. Th rest of the data is untouched. That's why I want to use  
saveField.
I want to reduce the overhead, reading all data, and storing all data  
which is even unchanged.

My first version of this snippet was like yours. But it had not  
worked anyway...



Am 25.09.2007 um 00:35 schrieb [EMAIL PROTECTED]:

>
> Alexander, ... I don't see all your code, so I'm guessing.
>
> I assume this is all happening in the save action in your contoller.
>
> And I'm guessing at a few names, but I think you'll get it...
>
> Why not do this (from the docs, but adapted to your question... I
> think):
>
> function edit($id)
> {
>    //Note: The musicianRequest model is automatically loaded for us at
> $this->MusicianRequest.
>
>    // Check to see if we have form data...
>    if (empty($this->data))
>    {
>         $this->MusicianRequest->id = $id;
>         $this->data = $this->MusicianRequest->read();//populate the
> form fields with the current row
>    }
>    else
>    {
>       /*
>       ** here's my deviation from the example for your field.
>       */
>       $this->data['MusicianRequest']['lifetime'] =
>         trim(date( "Y-m-d H:i:s",
>                        strtotime( "+4 weeks",
>                                      strtotime($this-
>> data['MusicianRequest']['lifetime']))));
>       /*
>       ** and from here on we continue as normal
>       */
>       // Here's where we try to save our data. Automagic validation
> checking
>       if ($this->MusicianRequest->save($this-
>> data['MusicianRequest']))
>       {
>          //Flash a message and redirect.
>          $this->flash('Your information has been saved.',
>                            '/properties/view/'.$this-
>> data['MusicianRequest']['id'], 2);
>       }
>       //if some fields are invalid or save fails the form will render
>    }
> }
>
> Jeff
>
> On Sep 23, 4:33 pm, cronet <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> i'm trying to save a single datefield. My Controller looks like this:
>>
>> -------------------------%<--------------------------------
>> // Set ID and lifetime
>> $this->MusicianRequest->id = $id;
>>
>> $lifetime = trim(date( "Y-m-d H:i:s", strtotime( "+4 weeks",
>> strtotime($this->data['MusicianRequest']['lifetime']) ) ) );
>>
>> echo $lifetime;  // FirstCase
>> $this->MusicianRequest->saveField('lifetime',$lifetime);  //
>> SecondCase
>> -------------------------%<--------------------------------
>>
>> What happens?
>> It shows me the right lifetime output in the FirstCase (e.g.
>> 2007-10-21 23:02:00), but the query looks like this:
>> UPDATE `musician_requests` SET `lifetime` = '2007-09-23 23:02:00'
>> WHERE `id` IN (6)
>>
>> Perhaps i create $lifetime the wrong way? But if I use a manual
>> created SQL query
>> -------------------------%<--------------------------------
>> $this->MusicianRequest->query( "UPDATE `musician_requests` SET
>> `lifetime` = '".$lifetime."' WHERE `id` IN (".$id.")" );
>> -------------------------%<--------------------------------
>>  it works....
>>
>> I think it's an cake related problem, cause the php echo output
>> displays the correct datetime.
>> The query cakephp creates, is definitly not the desired lifetime...
>>
>> Any ideas or hints?
>>
>> Regards,
>> Alexander
>
>
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to