Hi boyracerr, Thanks for your help. Cake is effectively amazing!!!
Kind Regards. On Mar 26, 4:10 am, boyracerr <[EMAIL PROTECTED]> wrote: > Me again, > > As so often, I knew I wanted to use it but needed a helpful post > laying it out for me in simple terms. Mariano to the rescue! > > http://www.cricava.com/blogs/index.php?blog=6&title=modelizing_habtm_... > > If you are using 1.2, then just set the table up like this (my > example): > > id, user_id, forum_id, role_id > > and the relation: > > var $hasAndBelongsToMany = array('Members' => array('className' => > 'User' > > ) > ); > > Yes, thats it. As usual, Cake is amazing but you need a blog post to > tell you why :) > > On Mar 26, 4:21 am, boyracerr <[EMAIL PROTECTED]> wrote: > > > As so often, stating my problem helped me think of it in a different > > way (actually it gave me different phrases to Google for) > > > Have a look at: > > >http://www.thinkingphp.org/2006/10/26/modeling-relationships-in-cakep... > > > I think this is what we are both trying to do. > > > If you are using 1.2, one of the comments on the above post might also > > be relevant: > > > """""""""" > > This is already halfway implemented in Cake 1.2, but only for MySQL, > > i.e.: > > > class User extends AppModel { > > > var $hasAndBelongsToMany = array("Group" => array("with" => > > "Memberships")); > > > } > > > And the join table fields will be selected as 'Memberships' within the > > association. > > > """""""""" > > > I'm going to try this now, let me know how you get on. > > > Ben > > > On Mar 26, 4:13 am, boyracerr <[EMAIL PROTECTED]> wrote: > > > > 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 cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---