Wednesday, July 29, 2009

Re: Saving both habtm and hasmany data

make sure that your array of data in $this->data is formatted
properly.

do a pr($this->data) in your save conditional to make sure its
formatted the right way
array(

[Model1]=>array([Model1.field1], [Model1.field2]),
[Model2]=>array([Model2.field1], [Model2.field1]),

)

saveAll should be able to interpret all that data if you set up your
associations correctly.

what does it say in your sql log?

On Jul 29, 3:38 pm, Site Reference <daoustm...@gmail.com> wrote:
> After quite a bit of back and forth, I decided to forge ahead with
> CakePHP for the first time.  I am running into troubles right now
> trying to get certain data to save properly.
>
> The form I am using is attempting to save data to several different
> models:
>
> phones
> emails
> profiles
> businesses
>
> The relationship of these models is as follows:
>
> profiles hasMany phones and emails
> businesses HABTM profiles
>
> Now my form allows people to fill out information about themselves
> (and thus add a profile) and submit it on behalf of their business.  I
> need cake to enter in profile, save the phone and email, then enter in
> the business, and make the habtm relationship.
>
> I was hoping cake could do all of this 'automagically', but it doesn't
> seem to be working.What I currently have is:
>
>             $this->Business->Profile->saveAll($this->data);
>             $this->Business->saveAll($this->data);
>
> Can cake do this automatically, or will I have to step cake through
> the saves?
--~--~---------~--~----~------------~-------~--~----~
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: