Hi, sorry for jumping in your post, but I think my situation is almost
exactly the same.

Imagine I have a forum application with many forums, so that we have

Users
Forums

A user may be an admin for one forum, a member of another, a moderator
of another. There is a table for Roles.

What is the best way to represent this relationship?

Like Guillaume, I'm thinking a foreign key in the forums_users table
which goes to Roles. This seems logical to me.

I'm sure many people must have faced this (essentially a three way
relation) but I can't find a decent solution.

Ben



On Mar 25, 11:57 pm, Guillaume Chomat <[EMAIL PROTECTED]>
wrote:
> Hi logica,
>
> Don't focus on the cohérence of the sample used to explain my needs.
> It is just a weird example.
> What i need is to know if it is possible when defining a HABTM
> relationship to tell cake to resolve also the foreign key contained in
> the join table.
>
> Can you help me on this?
>
> Thanks in advance.
>
> On Mar 25, 5:17 pm, "b logica" <[EMAIL PROTECTED]> wrote:
>
> > I suspect that you'd be far better off with role_id in the users
> > table. Unless it denotes a particular role (among many) that a user
> > had when making the post.
>
> > users belongsTo roles, HABTM posts
> > posts HABTM  users
> > posts_users (user_id, post_id)
>
> > On Tue, Mar 25, 2008 at 5:35 AM, Guillaume Chomat
>
> > <[EMAIL PROTECTED]> wrote:
>
> > >  Hi everybody,
>
> > >  Is cake able to read any referenced model in a join table?
>
> > >  Suppose we have three entities table:
> > >  - users
> > >  - posts
> > >  - roles
>
> > >  and a join table:
> > >  - posts_users.
>
> > >  The join table posts_users has a field role_id, foreign key to the
> > >  roles table.
>
> > >  We have defined the HABTM relationship in the user model.
> > >  So now, we would like to be able to read the posts associated to the
> > >  user but also get the role specified in the relation.
>
> > >  Is it possible without defining the finderQuery field in the HABTM
> > >  relationship?
>
> > >  Thanks in advance for your help
>
> > >  Kind Regards
--~--~---------~--~----~------------~-------~--~----~
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