I have a HABTM relation between Games
and Participants
. I need to find a Game
which has Participants
with IDs 1
and 2
"bound" to it. How to achieve this?
I tried with
$options['conditions']['participant_id'] = array('1', '2');
$game = $this->GamesParticipant->find('first', $options);
Which does not work, because the SQL query ends up with a WHERE participant_id IN (1, 2)
and this is not what I'm trying to achieve (it finds the first Game
with either Participant
1
or 2
not one which has both). Any advice?