【发布时间】:2014-05-08 19:45:34
【问题描述】:
我在 Games 和 Participants 之间有一个 HABTM 关系。我需要找到一个Game,它有Participants,ID 为1 和2“绑定”到它。如何做到这一点?
我试过了
$options['conditions']['participant_id'] = array('1', '2');
$game = $this->GamesParticipant->find('first', $options);
这不起作用,因为 SQL 查询以 WHERE participant_id IN (1, 2) 结束,这不是我想要实现的(它找到第一个 Game 与 Participant 1 或 2不是具有两者的)。有什么建议吗?
【问题讨论】:
标签: sql cakephp has-and-belongs-to-many