Sorry, I guess meant saveAll() which came to mind when you mentioned
__saveMulti().
But at a quick glance, saveAll does not look like the answer.

in __saveMulti I imagine that the problem is that when creating new
links it looks like you end up at "$db->insertMulti..."(line 1334)
which bypasses the model. But it also looks like I could try to
reformat the array to a more "normal" data array for saves and have
save called on the joining model... must try that later today.

Where does this stuff get tested? I can't find any tests that use a
"with" habtm in the core tests. Locating where they test this would
probably help a lot.

/Martin




On Jan 21, 9:19 am, brian <[email protected]> wrote:
> no! That method's private to Model. I meant, have a look through it
> (and save) to see what's happening internally.
>
> On Wed, Jan 21, 2009 at 2:41 AM, Martin Westin
>
> <[email protected]> wrote:
>
> > Thanks for the tip brian.
> > Guess I'll have a go at switching from save to saveMulti and see what
> > happens.
>
> > /Martin
>
> > On Jan 20, 8:20 pm, brian <[email protected]> wrote:
> >> Have a look in Model::__saveMulti(). I still haven't quite figured out
> >> the logic but the HABTM model's save() is called (which would trigger
> >> its callbacks) in some instances. But it's still a bit foggy to
> >> myself, as well. For instance, the block beginning at line 1286
> >> starting with:
>
> >> foreach ((array)$data as $row) {
>
> >> ... doesn't make any sense to me at all. I can't understand how that
> >> could work properly.
>
> >> On Tue, Jan 20, 2009 at 5:02 AM, Martin Westin
>
> >> <[email protected]> wrote:
>
> >> > bump...
>
> >> > My current working theory is that for some (to me) unknown reason
> >> > (performance?) habtm relationships are created and deleted without
> >> > fully utilizing the joining model. That is when you do:
>
> >> > $data = array(
> >> >  'A' => stuff for A,
> >> >  'B' =>array('B'=>array(1,3,4))
> >> > );
> >> > $this->A->save($data);
>
> >> > So I am thinking that I have to change the way I save these.
> >> > Possibly I need to g as far as using $this->AB->delete() directly for
> >> > unlinking.
>
> >> > And, or-course, anyone who has been down this road before could be of
> >> > great help by nudging me in the right direction.
>
> >> > Non-essential background information:
> >> > The reason I want to use the save and delete callbacks is that I want
> >> > to put together a custom "counterCache" for a habtm relationship. That
> >> > is why I want to trigger an update each time a "link" is created or
> >> > deleted.
>
> >> > /Martin
>
> >> > On Jan 19, 8:56 am, Martin Westin <[email protected]> wrote:
> >> >> Hi there,
>
> >> >> I am trying to make use of a JoinModel for the first time but can't
> >> >> get the hang of it. First I had some problems getting the class to
> >> >> load at all but that is taken care of. Now I cant get all the
> >> >> callbacks to fire.
>
> >> >> I create associations between records of my two models expecting
> >> >> beforeSave and afterSave to fire. But they don't.
>
> >> >> I know the joining model is being used ($this->ModelA->ModelAsModelB
> >> >> == instance of my expected class) and callbacks beforeFind and
> >> >> afterFind are firing.
>
> >> >> I found two old posts. One suggested using beforeSave (for whatever
> >> >> purpose), suggesting to me that they should fire. The other suggested
> >> >> using a callback on one of the "primary" models to call a custom
> >> >> method on the joining model, suggesting that the callbacks should in
> >> >> fact not fire.
>
> >> >> Looking at the models used in the core tests I found no joining model
> >> >> with any callback defined.
>
> >> >> Does this mean that a joining model is really only "half a model"?
> >> >> Since I haven't found anything to clearly state the opposite I have
> >> >> expected these models to behave like any other once created. can
> >> >> anyone clear the fog a little for me?
>
> >> >> /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