Wednesday, September 30, 2009

Re: Associating model aliases

Ok, I think I found another bit of the puzzle...

Problem was wrong: model aliases do retain the associations of
the original models, after all.

But (thank you John for pointing in that direction) the default value
of Model recursive property seems to be 1.

If I set it to 2

<?php
class Message extends AppModel {
...
var $recursive = 2;
...
}
?>

then I get also the Profile data for each Sender and Recipient.

But, and is another BIG but:
* I get as well a lot of unwanted data (that can be contained /
unbound)
* data are obtained with a recursion of queries, each Profile found
with one query...

So up to now the "ad hoc" join (thank you Brian) is to me the more
efficient solution, everything with the same query with 2 additional
LEFT JOINs.

I look forward to your comments.

Best,

Mario

On Sep 30, 2:17 am, brian <bally.z...@gmail.com> wrote:
> On Tue, Sep 29, 2009 at 5:21 PM, Mario <mario.calli...@gmail.com> wrote:
>
> > But to me the BIG question is:
> > isn't there a simpler and more elegant way in Cake to reach the same
> > result?
>
> > I feel there should be; because the kind of problem, if I understood
> > it correctly (that is: model alias does not retain the associations of
> > the original model), seems to me quite broad and frequent.
>
> > I wonder if, for example, if (in this specific case) declaring the
> > Sender and Receiver models, therefore having the model/sender.php and
> > model/receiver.php files, could be a possible solution to be explored.
>
> > I look forward to your comments.
>
> I actually think it is pretty elegant. But, if you're doing this a
> lot, I suppose it would just be tedious. It seems like something that
> a Behavior would do very well. There may already be such a thing at
> the Bakery.
--~--~---------~--~----~------------~-------~--~----~
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: