Cakephp, Retreive Data for HABTM Models using find

Posted by user298079 on Stack Overflow See other posts from Stack Overflow or by user298079
Published on 2010-03-20T16:46:55Z Indexed on 2010/03/20 16:51 UTC
Read the original article Hit count: 263

Filed under:
|
|

I am new to cakephp and I'm trying to accomplish something that should be relatively easy. I have 2 models projects & categories bind by HABTM relationship.

I am trying to perform the following query -> find all projects that belong to a category

$projects = $this->Project->find('all', array('conditions' => array('Category.slug' => $category)));

However when I'm doing so it generates an SQL error:

SQL Error: 1054: Unknown column 'Category.slug' in 'where clause' 

What am I doing wrong??

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about habtm