user at a time, but not more than one :(
is there any other specific setting that i need to take care of?
On Jul 28, 3:40 am, DCrews <cre...@gmail.com> wrote:
> if $this->data is structured like the following:
>
> array(
> ['User'] = array(
> 'id' = xxx
> ),
> ['Profile'] = array(
> [0] = array(
> 'id' = xxx,
> 'whatever' = whatever,
> etc...
> [1] = array(
> 'id' = xxx,
> 'whatever' = whatever,
> etc...
> )
> )
> and you have HABTM in your models, you can do
>
> $this->User->saveAll($this->data);
>
> And it'll save them all. I haven't tried anything like saving multiple
> users all at once each with multiple profiles, but I imagine it'd
> require setting the recursive up a little, but still doable.
>
> On Jul 27, 5:13 pm, sanedevil <sanede...@gmail.com> wrote:
>
> > Thanks Norman,
> > However, it dint work :(
>
> > The problem is that I can't save multiple links of Profile and User. I
> > can only do one at a time.
>
> > hence, $data['Profile']['id'] = 1234 works, but $data['Profile'][0]
> > ['id'] = 1234 doesn't work :(
>
> > any lights?
>
> > On Jul 27, 1:15 am, Norman Paniagua <normanpania...@gmail.com> wrote:
>
> > > Try
>
> > > $data['User']['id'] = 1010;
> > > $data['Profile'][0]['id'] = 1234;
> > > $data['Profile'][1]['id'] = 5678;
>
> > > foreach ($data['Profile'] as $i=>$v):
> > > $data['Profile'][$i]['user_id'] = $data['User']['id'];
> > > endforeach;
>
> > > $this->User->save($data);
> > > $this->User-->Profile->saveAll($data);
>
> > > I dont know if doing $this->User->saveAll($data) will save the User and
> > > Profile data
> > > ---
>
> > > Norman Paniagua
>
> > > 2010/7/26 sanedevil <sanede...@gmail.com>
>
> > > > For my problem, a User HABTM Profiles
>
> > > > A user can select multiple profiles via a screen. I get these values
> > > > in my controller. I want to "link" all these profiles with the user.
> > > > Currently i'm doing:
>
> > > > $profile_1['Profile']['id'] = 1234; //the profile id
> > > > $profile_1['User']['id'] = 1010; // The user id
> > > > $this->User->save($profile_1);
>
> > > > $profile_2['Profile']['id'] = 5678; //the profile id
> > > > $profile_2['User']['id'] = 1010; // The user id same as
> > > > before
> > > > $this->User->save($profile_2);
>
> > > > However, this creates only the 2nd link in the HABTM table.
>
> > > > Is there a way that I can create both the links (1010-1234 and
> > > > 1010-5678) in a single shot?
>
> > > > Thanks!
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers
> > > > with their CakePHP related questions.
>
> > > > 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+unsubscribe@googlegroups.com<cake-php%2Bunsubscr...@googlegroups.com>For more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=en-Hide quoted text -
>
> > - Show quoted text -
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment