title: CakePHP how to retrieve HABTM data with conditions?
body: <p>I use CakePHP 2.2.2
  I have 3 tables: restaurants, kitchens and kitchens_restaurants - join table for HABTM.</p>
  
  <p>In Restaurant model I have: </p>
  
  <pre><code>public $hasAndBelongsToMany = array(
      'Kitchen' =&gt;
          array(
              'className'              =&gt; 'Kitchen',
              'joinTable'              =&gt; 'kitchens_restaurants',
              'foreignKey'             =&gt; 'restaurant_id',
              'associationForeignKey'  =&gt; 'kitchen_id',
              'unique'                 =&gt; true,
              'conditions'             =&gt; '',
              'fields'                 =&gt; 'kitchen',
              'order'                  =&gt; '',
              'limit'                  =&gt; '',
              'offset'                 =&gt; '',
          ),
  </code></pre>
  
  <p>The problem is that I have separate controller for my main page in which I need to retrieve data from this models with complex conditions.</p>
  
  <p>I added </p>
  
  <pre><code>public $uses = array('Restaurant');
  </code></pre>
  
  <p>to my main page controller and here comes the part where I need your advices.</p>
  
  <p>I need to select only those restaurants where kitchen = $id.
  I've tried to add </p>
  
  <pre><code>public function index() {   
  $this-&gt;set('rests', $this-&gt;Restaurant-&gt;find('all', array(
  'conditions' =&gt; array('Restaurant.active' =&gt; "1", 'Kitchen.id' =&gt; "1")
  )));
  
  }
  </code></pre>
  
  <p>and I got SQLSTATE[42S22]: Column not found: 1054 Unknown column in 'where clause' error.
  Obviously I need to fetch data from "HABTM join table" but I don't know how.</p>