title: CakePHP find() and related models and conditions
body: <p>I am calling find() on my Game model in order to get the reviews of that game for a particular platform. The problem is that the find() call doesn't seem to be paying attention to my conditions array. The call returns all the reviews for a game regardless of the platform_id.</p>
  
  <p>I have these model associations:</p>
  
  <ul>
  <li>User hasMany Review</li>
  <li>Game hasMany Review</li>
  <li>Review belongsTo Game</li>
  <li>Review belongsTo User</li>
  <li>Game HABTM Platform</li>
  </ul>
  
  <p>This is the find call that I created:</p>
  
  <pre><code>    $options = array(
          'group' =&gt; array(
              'Game.id'
          ),
          'joins' =&gt; array(
              array(
                  'table' =&gt; 'reviews',
                  'type' =&gt; 'LEFT',
                  'conditions' =&gt; array(
                      'Game.id=reviews.game_id'
                  )
              ),
              array(
                  'table' =&gt; 'platforms',
                  'type' =&gt; 'LEFT',
                  'conditions' =&gt; array(
                      'reviews.platform_id=platforms.id'
                  )
              ),
              array(
                  'table' =&gt; 'users',
                  'type' =&gt; 'LEFT',
                  'conditions' =&gt; array(
                      'reviews.user_id=users.id'
                  )
              )
          ),
          'fields' =&gt; array(
              'Game.id', 'Game.name',
              'platforms.id', 'platforms.name',
              'users.id', 'users.username'
          ),
          'conditions' =&gt; array(
              'AND' =&gt; array(
                  'NOT' =&gt; array('reviews.review_text' =&gt; NULL),
                  'platforms.id' =&gt; $pid,
              )
          ),
          'limit' =&gt; 5
      );
  
      $this-&gt;Game-&gt;find('all', $options);
  </code></pre>
  
  <p>Here is a sample return for a find() call for platform_id=2:</p>
  
  <pre><code>array(
  (int) 0 =&gt; array(
      'Game' =&gt; array(
          'id' =&gt; '58',
          'name' =&gt; 'Bioshock 2'
      ),
      'platforms' =&gt; array(
          'id' =&gt; '2',
          'name' =&gt; 'PlayStation 3'
      ),
      'users' =&gt; array(
          'id' =&gt; '20',
          'username' =&gt; 'pspmaniac'
      ),
      'Review' =&gt; array(
          (int) 0 =&gt; array(
              'id' =&gt; '32',
              'review_text' =&gt; 'This is the PC review.',
              'score' =&gt; '4',
              'user_id' =&gt; '20',
              'game_id' =&gt; '58',
              'created' =&gt; '2013-04-30 19:59:40',
              'platform_id' =&gt; '10'
          ),
          (int) 1 =&gt; array(
              'id' =&gt; '33',
              'review_text' =&gt; 'This is the PS3 review.',
              'score' =&gt; '7',
              'user_id' =&gt; '20',
              'game_id' =&gt; '58',
              'created' =&gt; '2013-04-30 20:00:04',
              'platform_id' =&gt; '2'
          ),
          (int) 2 =&gt; array(
              'id' =&gt; '34',
              'review_text' =&gt; 'This is the XBOX 360 review.',
              'score' =&gt; '6',
              'user_id' =&gt; '20',
              'game_id' =&gt; '58',
              'created' =&gt; '2013-04-30 20:00:22',
              'platform_id' =&gt; '1'
          )
      )
  )
  );
  </code></pre>
  
  <p>In the 'Review' index, it returns three reviews for the game (platform ids 10, 2, and 1) when it should only return the review with platform_id=2.</p>
  
  <p>This is my <code>reviews</code> table:</p>
  
  <pre><code>CREATE TABLE reviews
  (
     id mediumint unsigned not null auto_increment,
     review_text mediumint,
     score int not null,
     user_id mediumint unsigned not null,
     game_id mediumint unsigned not null,
     PRIMARY KEY (id),
     FOREIGN KEY (user_id) REFERENCES users (id),
     FOREIGN KEY (game_id) REFERENCES games (id)
  );
  </code></pre>
  
  <p>So, in the end, the only thing wrong with the returned array is that it contains reviews not only for the condition 'platforms.id=2' but for all platform ids.</p>