cakephp habtm join问题

我有如下表结构:
events (boxing, sparring etc)
competitors (users who are participating into diff events)
events_competitors (every competitor's selected events will go here)
现在我想要的是,根据我的比赛时间表,我想从
schedules
表中找到
competitors
,其中每个
competitors
将与他们在注册时选择的
events
匹配。 我正在使用这样的查找查询:
$matchdivisions = $this->Competitor->find("all" , array(
                                                'conditions' => array('Competitor.status' => 1, 
                                                'Competitor.payment_completed' => 1,
                                                'Competitor.weightgroup_id' => $current_matchsc['Matchschedule']['weightgroup_id'],
                                                'Competitor.rank_id' => $current_matchsc['Matchschedule']['rank_id'],
                                                'Competitor.degree_id' => $current_matchsc['Matchschedule']['degree_id'],
                                                'Competitor.gender' => $current_matchsc['Matchschedule']['gender'],

                                                        ),

                                            'joins' => array(

                                                     array('table' => 'event_competitors',
                                                           'alias' => 'EventCompetitor',
                                                           'type' => 'left',
                                                           'conditions'=> array('EventCompetitor.event_id = '.$current_matchsc['Event']['id']),
                                                          ) 
                                                        )
                                )
);
在这里,我使用了连接,因为我无法找到
EventCompetitor
Competitors
Events
匹配的关系。 问题:单个匹配记录是10次,因为
join
,而它应该只是单次。 最早的回复将不胜感激。 提前致谢! 一旦这对我有用,现在是下一个级别: 我有两个级别的条件检查,在
EventsCompetitors
我想看,如果他们想要与
black
腰带打架或者如果他们是轻微的他们想要与
adults
战斗所以在这种情况下,我想看到这两个标志在此基础上,我的条件将再次改变,我的附加显示将显示新的结果。 请告诉我,如果有人有人对CakePHP这类东西有所了解。 再次感谢stackoverflow提供的优质服务!     
已邀请:
如果您只对单个记录感兴趣并且始终确保其他记录是重复的,那么您可以使用find('first',...)代替。 如果您对多个不同的记录感兴趣,但是您获得的每个记录的倍数都可以添加到
'group' => array('')
以汇总特定字段上的竞争对手,只返回一次?     

要回复问题请先登录注册