I just overwrote the saveAll() function in the Location model and
saved the deep-level-association manually in order to rollback the
whole transaction when validation fails. So the code in the Cakebin is
just some kind of a wrapper.

Yeah, maybe the "recursion problem" is the reason why saveAll() only
saves the first level associations. I think to get the deep-level-
thing to work, the structure of the data array should also reflect the
relation structure: nested arrays instead of all models on the same
level. I don't know ;-)

I'm looking forward to the saveAll() section at
book.cakephp.org ... :-)

Regards, Christoph


On 1 Sep., 16:37, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Thanks Preloader.
> I have done something similar so far but thought I'd check if saveAll
> had some hidden functionality.
>
> Funny thing is that for hasMany (at least) you don't need saveAll to
> save associated data... save does the job just fine for me... So
> saveAll would work if it did not cut away at the data-array before
> saving associations.
>
> if Page hasMany Paragraph and I save to Page with Paragraph-data in
> the array it gets saved too, without saveAll.
> But if I saveAll in Post then Page will only ever see data for the
> Page model and not any of the other data so it has no way of finding
> Paragraph-data and save it like it normally would.
>
> I think your pastebin code would work even without creating the new
> arrays. I think it is the fact that you are using the public save/
> saveAll that makes a lot of difference. (model.php uses __save) Since
> model.php does not do this I guess there could be some problems with
> infinite recursions when saving data where the association is defined
> both ways? (nothing I have seen here)
>
> Thanks for replying.
> /Martin
>
> On Sep 1, 3:57 pm, Preloader <[EMAIL PROTECTED]> wrote:
>
> > Hello Martin,
>
> > no, it does not seem to work for deeper levels.
>
> > I hacked the saveAll() method in the main model, maybe it helps you:
>
> >http://bin.cakephp.org/view/1083645660
>
> > Location hasOne Address
> > Location hasOne Contact (contact person)
> > Contact hasOne Address (alias: CAddress)
>
> > Regards, Christoph
>
> > On 1 Sep., 15:22, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > Hi guys,
> > > I was going to rewrite some older code to use saveAll() and found that
> > > saveAll seems built for "only" a single level of association. Is that
> > > right or is my data-array possibly in the wrong format?
>
> > > For example:
> > > Article hasMany Page, Page hasMany Paragraph
> > > I am able to save Article and Page data but have not been able to save
> > > Paragraph data at the same time using saveAll.
> > > I just wanted to check that this is correct and that I have not simply
> > > missed some trick needed to get it to work. Looking at model.php it
> > > looks like it only saves direct associations for the current model and
> > > no "recursive" models.
>
> > > regards
> > > Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to