[email protected]
[Top] [All Lists]

Building a 2-level relationship

Subject: Building a 2-level relationship
From: WhyNotSmile
Date: Thu, 24 Jun 2010 10:09:31 -0700 PDT
I have the following structure:

Group - hasMany Users (user has foreign key called group_id)
User - hasMany Children (child has foreign key called user_id)
        - belongsTo Group (based on group_id)
Child - belongsTo User (based on user_id)

My question is this: is there a way to define the Child realtionship
to the group?  E.g., when finding Children, I want to be able to loop
over each Group and find all the Children in each one, but the Child
model doesn't know that Group exists.

I have looked at the Tree behaviour, but it looks like it's more
complicated than I need.

Any advice is appreciated.


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 

<Prev in Thread] Current Thread [Next in Thread>