That doesn't necessarily break convention. If he is storing additional
data in the join table, then Cake's automatic joins via the HABTM
relationship don't work so well. In that case, he's better off just
manually joining the tables through two sets of hasMany/belongsTo
relationships as per the cookbook (http://book.cakephp.org/view/85/
Saving-Related-Model-Data-HABTM). And in that case, GroupMembership is
a very appropriate model name and is more descriptive than UsersGroup.

Even if you decide to stick with the HABTM relationship, it's still
sometimes appropriate to give the "join model" a natural name. This
makes the functional role of that model (e.g. semantic relationships
to other models) much more obvious and intuitive. Using model names
like UsersGroup or UsersUsers or ContractorsCompany is much less
intuitive than simply naming them Membership or Friendship or
Contract. And if you define your problem domain or business objects
incorrectly, then you're going to end up with much bigger problems
than simply the hassles of manually specifying join tables.

On May 16, 2:28 am, WebbedIT <[email protected]> wrote:
> Surrender to conventions, it will make your life so much easier in the
> long run!  I.e. call your joinModel GroupsUser (table: groups_users)
> rather than GroupsMembership.
>
> Try:
>
> // fetch array of group ids
> $groups = $this->User->GroupsUser->find('list', array(
>   'fields'=>array('GroupsUser.group_id', 'GroupsUser.group_id'),
>   'conditions'=>array('GroupsUser.user_id'=>$user_id)
> ));
>
> // find related posts
> $posts = $this->User->GroupsUser->Group->GroupPost->find('all', array(
>   'conditions'=>array('GroupPost.group_id'=>$groups)
> ));
>
> HTH
>
> Paul
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> athttp://groups.google.com/group/cake-php?hl=en

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 
http://groups.google.com/group/cake-php?hl=en

Reply via email to