Monday, September 29, 2008

Re: May or may not have one relationship

Polymorphic behavior on bakery helped me .. just fyi.. in case some one else is also stuck in such a situation.

Thanks.

On Mon, Sep 29, 2008 at 1:15 PM, grigri <jp@hendersonwebdesign.com> wrote:

Doesn't really seem much point.

When retrieving an `Entity`, cake will as for the join to be performed
so that both entries will be retrieved in a single query.

To only retrieve the `User` on a condition in the `Entity` table,
you'd have to first retrieve the `Entity` and then (sometimes)
retrieve the `User`. The overhead of a separate query is much higher
than a join that will never happen, assuming your tables are indexed
correctly.

You can always conditionally delete the empty User() array from the
results in afterFind(), if you feel it's necessary.

hth
grigri

On Sep 28, 9:15 am, "Novice Programmer" <novice.prog...@gmail.com>
wrote:
> Hello All,
>
> This might be an awkward situation but for my current project i am having a
> situation where a table Entity may or not have a user. In the entities table
> there is a field which tells me whether there is some user associated with
> it or not. I want to handle the situation with cake php so that it tries to
> join Entity with User only when that particular field in entity is set. Is
> there some out there to help me?
>
> --
> Thanks & Regards,
> Novice.




--
Thanks & Regards,
Novice.

--~--~---------~--~----~------------~-------~--~----~
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: