Save() multiple times not working?

4 messages Options
Embed this post
Permalink
GoalTribe

Save() multiple times not working?

Reply Threaded More More options
Print post
Permalink

Why doesn't save() work multiple times in the same action?

I have an action that my cron job calls to see which members need
reminders.

It loops through all members to check. I would like to add an entry
into my event log table for each member that gets a reminder. However,
only the first call to save() seems to work.

What am I doing wrong?

Here is my code:

                               $new_event_data2 = array(
                                                'Event' => array(
                                                                                'user_id' => $fbid,
                                                                                'event' => "email",
                                                                                )
                                                                        );

                                                $this->Event->save($new_event_data2);

Thanks so much for your help!

This is for a Facebook App called "The 30 Day Fitness Challenge"
running on CakePHP. See it live here: http://www.facebook.com/apps/application.php?id=143111604747

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

hunny-2

Re: Save() multiple times not working?

Reply Threaded More More options
Print post
Permalink

After the call $this->Event->save($new_event_data2);
Write the following line

$this->Event->id = null;

It should work fine.




On Nov 5, 4:21 am, GoalTribe <[hidden email]> wrote:

> Why doesn't save() work multiple times in the same action?
>
> I have an action that my cron job calls to see which members need
> reminders.
>
> It loops through all members to check. I would like to add an entry
> into my event log table for each member that gets a reminder. However,
> only the first call to save() seems to work.
>
> What am I doing wrong?
>
> Here is my code:
>
>                                $new_event_data2 = array(
>                                                 'Event' =>   array(
>                                                                                 'user_id'       =>   $fbid,
>                                                                                 'event' =>   "email",
>                                                                                 )
>                                                                         );
>
>                                                 $this->Event->save($new_event_data2);
>
> Thanks so much for your help!
>
> This is for a Facebook App called "The 30 Day Fitness Challenge"
> running on CakePHP. See it live here:http://www.facebook.com/apps/application.php?id=143111604747
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Miles J

Re: Save() multiple times not working?

Reply Threaded More More options
Print post
Permalink

Or call $this->Event->create() before the next save.

On Nov 4, 10:41 pm, hunny <[hidden email]> wrote:

> After the call $this->Event->save($new_event_data2);
> Write the following line
>
> $this->Event->id = null;
>
> It should work fine.
>
> On Nov 5, 4:21 am, GoalTribe <[hidden email]> wrote:
>
> > Why doesn't save() work multiple times in the same action?
>
> > I have an action that my cron job calls to see which members need
> > reminders.
>
> > It loops through all members to check. I would like to add an entry
> > into my event log table for each member that gets a reminder. However,
> > only the first call to save() seems to work.
>
> > What am I doing wrong?
>
> > Here is my code:
>
> >                                $new_event_data2 = array(
> >                                                 'Event' =>   array(
> >                                                                                 'user_id'       =>   $fbid,
> >                                                                                 'event' =>   "email",
> >                                                                                 )
> >                                                                         );
>
> >                                                 $this->Event->save($new_event_data2);
>
> > Thanks so much for your help!
>
> > This is for a Facebook App called "The 30 Day Fitness Challenge"
> > running on CakePHP. See it live here:http://www.facebook.com/apps/application.php?id=143111604747
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

GoalTribe

Re: Save() multiple times not working?

Reply Threaded More More options
Print post
Permalink

Excellent! $this->Event->create()  worked perfectly.

Thanks Miles & hunny!


On Nov 4, 10:53 pm, Miles J <[hidden email]> wrote:

> Or call $this->Event->create() before the nextsave.
>
> On Nov 4, 10:41 pm, hunny <[hidden email]> wrote:
>
> > After the call $this->Event->save($new_event_data2);
> > Write the following line
>
> > $this->Event->id = null;
>
> > It should work fine.
>
> > On Nov 5, 4:21 am, GoalTribe <[hidden email]> wrote:
>
> > > Why doesn'tsave() workmultipletimesin the same action?
>
> > > I have an action that my cron job calls to see which members need
> > > reminders.
>
> > > It loops through all members to check. I would like to add an entry
> > > into my event log table for each member that gets a reminder. However,
> > > only the first call tosave() seems to work.
>
> > > What am I doing wrong?
>
> > > Here is my code:
>
> > >                                $new_event_data2 = array(
> > >                                                 'Event' =>   array(
> > >                                                                                 'user_id'       =>   $fbid,
> > >                                                                                 'event' =>   "email",
> > >                                                                                 )
> > >                                                                         );
>
> > >                                                 $this->Event->save($new_event_data2);
>
> > > Thanks so much for your help!
>
> > > This is for a Facebook App called "The 30 Day Fitness Challenge"
> > > running on CakePHP. See it live here:http://www.facebook.com/apps/application.php?id=143111604747
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---