Relationships can be either declared on one end or both ends. If you
know that you will only need the related data when going Post->Tag but
never Tag->Post you can leave the relation out of the Tag model and
gain some speed dure to less database access.

I have found that there are huge speed-gains to be had from paying
attention to relations and recursion. Only using them when actually
needed. I managed to get an app of mine to run 3 times (yes that is a
lot) faster on each request by reducing recursion by one level on a
frequently used model and at the same time dropping a "returning"
relation that would otherwise had been part of a lot of requests for
nothing.



On Jan 24, 11:42 am, bob <[EMAIL PROTECTED]> wrote:
> Another related question: in their post tag HABTM example, in the Post
> model, they defined a HABTM for Tag. For the Tag model, we would need a
> HABTM for Post as well correct?
>
> On Jan 24, 2008 2:38 AM, bob <[EMAIL PROTECTED]> wrote:
>
> > This is a newbie question. In the cakephp manual (
> >http://manual.cakephp.org/chapter/models)
>
> > $this->data['Comment']['post_id'] = $post_id;
>
> >         //Because our Post hasMany Comments, we can access
> >         //the Comment model through the Post model:
>
> >         $this->Post->Comment->save($this->data);
>
> > Why do we need to do $this->Post->Comment->save($this->data) instead of
> > simply $this->Comment->save($this->data)? what difference does it make in
> > this case, since we know the specific post_id?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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