CakePHP HABTM Filtering
Posted
by
James Haigh
on Stack Overflow
See other posts from Stack Overflow
or by James Haigh
Published on 2010-12-21T17:32:15Z
Indexed on
2010/12/22
3:54 UTC
Read the original article
Hit count: 216
Hi,
I've got two tables - users
and servers
, and for the HABTM relationship, users_servers
. Users HABTM servers and vice versa.
I'm trying to find a way for Cake to select the servers that a user is assigned to.
I'm trying things like $this->User->Server->find('all');
which just returns all the servers, regardless of whether they belong to the user.
$this->User->Server->find('all', array('conditions' => array('Server.user_id' => 1)))
just gives an unknown column SQL error.
I'm sure I'm missing something obvious but just need someone to point me in the right direction.
Thanks!
© Stack Overflow or respective owner