You could do something like this: Add a field in the posts table named type and do the associations like this:
var $hasAndBelongsToMany = array( // this here is the HABTM for teams 'Team' => array( 'className' => 'Tag', 'joinTable' => 'posts_teams', 'foreignKey' => 'post_id', 'associationForeignKey' => 'team_id', 'unique' => true, 'conditions' => array('Post.type' => 't') ), // and this is the HABTM for groups 'Group' => array( 'className' => 'Group', 'joinTable' => 'posts_groups', 'foreignKey' => 'post_id', 'associationForeignKey' => 'group_id', 'unique' => true, 'conditions' => array('Post.type' => 'g') ) ); and in the other models you put the condition the same Post.type => "type" Don't know for sure if it works, i just used it on hasMany relations not on HABTM, but if things are the same it should work just fine. Good luck. On Sat, 2009-05-02 at 13:06 -0700, Miles J wrote: > So I am building a forum system, that will be used for multiple areas. > The table structure is as follows. > > posts > posts_teams > posts_groups > topics > topics_teams > topics_groups > > For example, all the posts tables are identical, except for the fact > that posts_teams is only teams posts, and posts_groups is only for > groups. > > I want to be able to use only ONE model (posts) that can manipulate > all 3 tables. Since they are all the same data and structure, I don't > want to have duplicate a single model 3 times. Is there a method for > this already, or a behavior? > > If not I think ill go ahead and develop one. > > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---