title: CakePHP - Find conditions for related model
body: <p>I have SubjectGroup, which hasMany Subject.</p>
  
  <pre><code>class SubjectGroup extends AppModel {
  
      public $hasMany = array(
          'Subject' =&gt; array('order' =&gt; 'Subject.name')
      );
  
  }
  
  class Subject extends AppModel {
  
      public $belongsTo = array('SubjectGroup');
  
  }
  </code></pre>
  
  <p>I want to get all SubjectGroups, and recursively retrieve their Subjects, but only the Subjects that have a status of 2.  I can't figure out how to do this.</p>
  
  <pre><code>$subjectGroups = $this-&gt;SubjectGroup-&gt;find('all', array(
      'conditions' =&gt; array('Subject.status !=' =&gt; 2),
      'order' =&gt; 'SubjectGroup.name'
  ));
  </code></pre>
  
  <p><strong>Warning (512): SQL Error: 1054: Unknown column 'Subject.status' in 'where clause'</strong></p>
  
  <p>Note: I have read that I can add a conditions array to the model relationship definition, but I don't want the relationship to always use the condition.  Sometimes I will want to just retrieve the SubjectGroups and Subjects with status 2, and sometimes the SubjectGroups with all Subjects, regardless of their status.</p>
  
  <p><strong>PROGRESS</strong></p>
  
  <p>With some help from Ross, I now am trying to use the Containable behaviour.  I have this so far:</p>
  
  <pre><code>$this-&gt;SubjectGroup-&gt;find('all', array(
      'contain' =&gt; 'Subject.status != 2',
      'order' =&gt; 'SubjectGroup.name'
  ));
  </code></pre>
  
  <p>There are no errors, but it returns all Subjects, even the ones with status = 2.</p>