title: CakePHP find related model data
body: <p>I got classes User and Firm:</p>
  
  <pre><code>class Firm extends AppModel {
      var $name = 'Firm';
      var $belongsTo = 'User';
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>class User extends AppModel {
      var $name = 'User';
      var $hasMany ='Post';
      var $hasAndBelongsToMany = 'Firm';
  }
  </code></pre>
  
  <p>everything works fine, but how do I search Firm if user id = for example, 5?
  I used:</p>
  
  <pre><code>$this-&gt;set('firms',$this-&gt;Firm-&gt;User-&gt;find('all', array('conditions'=&gt;array('User.id'=&gt;'5'))));
  </code></pre>
  
  <p>and on my view i put:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Firma&lt;/th&gt;
      &lt;/tr&gt;
      &lt;?php foreach($firms as $firm): ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $firm ['Firm']['firm_id']; ?&gt;&lt;/td&gt;  //line 9
      &lt;/tr&gt;
      &lt;?php endforeach; ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>But when I enter my view I get the error:</p>
  
  <p><code>"Notice (8): Undefined index: firm_id [APP\views\firms\wylistuj.ctp, line 9]"</code></p>