title: retrieve data from multiple tables in cakephp
body: <p>i am using cakephp 2.xx. i have two tables in my database names and genders. i write innerjoin to display names with their gender. gender is coming from genders table. my controller is below</p>
  
  <pre><code>class NamesController extends AppController {
  public $helpers = array("Html", "Form");
  public function index() {
      $this-&gt;loadModel("names");
  $query_options = array();
  $query_options["fields"] = array("names.Name","genders.gender");
  $query_options["joins"] = array("table" =&gt; "genders", "alias" =&gt; "genders", "type" =&gt; "INNER", "conditions" =&gt; array("genders.id = names.Gender_id",));
  $this-&gt;set("gender", $this-&gt;names-&gt;find('all', array($query_options,'limit' =&gt; 10 ,'recursive' =&gt; 1)));
  }
  }
  </code></pre>
  
  <p>names model is </p>
  
  <pre><code>class Names extends AppModel {  
       var $belongsTo = 'Genders';     
  }
  </code></pre>
  
  <p>and genders model is </p>
  
  <pre><code>class Genders extends AppModel {    
      var $hasMany = 'Names';
      }
  </code></pre>
  
  <p>and ctp code is</p>
  
  <pre><code>foreach ($gender as $post);
  echo $post["names"]["Name"];
  echo $post["genders"]["gender"];
  </code></pre>
  
  <p>this print Name fine. but doesn't print gender and result in Undefined index: genders. Please help</p>