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提供的优质服务!
没有找到相关结果
已邀请:
1 个回复
厦惫
以汇总特定字段上的竞争对手,只返回一次?