title: What's Going Wrong With My CakePHP HABTM Query?
body: <p>I have a table called Landmarks and a table called Categories with a HABTM relationship to each other.  I am trying to retrieve all the categories for a specific Landmark with the following code:</p>
  
  <pre><code>$this-&gt;set('selected_categories', $this-&gt;Category-&gt;find('list',
      array('contain'=&gt;array(
          'Landmarks'=&gt;array(
             'conditions'=&gt;array('Landmark.num'=&gt;7)
  )))));
  </code></pre>
  
  <p>I've tested the database query that results from this (as printed out in debug level 2), and it seems to get the right results, i.e. a subset of the Categories.  However, when I var_dump $selected_categories in the view, I'm getting a list of ALL categories instead. </p>
  
  <p>Am I missing something obvious here?</p>
  
  <p>ETA: I told a lie when I said the above query was working.  Something else on the page is generating the SQL query I want!  Which is:</p>
  
  <pre><code>SELECT `Categories`.`num`, `CategoriesLandmark`.`category_num`,
    `CategoriesLandmark`.`landmark_num` 
  FROM `categories` AS `Categories` JOIN `categories_landmarks` 
  AS `CategoriesLandmark` ON (`CategoriesLandmark`.`landmark_num` = 7
  AND `CategoriesLandmark`.`category_num` = `Categories`.`num`) WHERE 1 = 1
  </code></pre>