title: Relationship issue in YII
body: <p>I Have a GetStudents function in Agent model. where I fetch the students related to the agents.</p>
  
  <p>But I want to show more fields of students from another table
  Eg</p>
  
  <pre><code>**Agent table**  (agent has students)
  agent_id
  
  **student table**
  STUDENTID  pkey
  agent_id
  
  **relation table** (this table creates relation between student and household)
  StudentID  HOUSEHOLDID
  
  **HOUSEHOLD TABLE** 
  HouseHOLDID   Householdname
  </code></pre>
  
  <p>I want to fetch householdname when I fetch all student details.</p>
  
  <p>really looking bazzare to me as I am newbie to YII</p>
  
  <p>MY function in agent model.</p>
  
  <pre><code>public static function getStudents($id) {
          $relationships = Relationship::model()-&gt;findAll('type = :type AND source = :agent_id', array(':type' =&gt; 2, ':agent_id' =&gt; $id));
          //$relationships=sort($relationships);
          // Generate relationship array
  
          //print_r($relationships);
          foreach ($relationships as $relationship) {
              $in[] = $relationship-&gt;destination;
          }
  
          // Generate db condition
          $criteria = new CDbCriteria;
          if (! isset($in) || ! is_array($in) || sizeOf($in) == 0) {
              $in[] = -999;
          }
          $criteria-&gt;addInCondition('StudentID', $in, 'OR');
  
  
  
          return new CActiveDataProvider('Student', array(
              'criteria' =&gt; $criteria,
              'sort'=&gt;array('defaultOrder'=&gt;array(
      'StudentID'=&gt;CSort::SORT_DESC,
  )),
          ));
      } 
  </code></pre>
  
  <p>My code to fetch data in  by passing ID into it</p>
  
  <pre><code>&lt;?php $this-&gt;widget('zii.widgets.CDetailView', array(
      'data' =&gt; $model,
      'attributes' =&gt; array(
  array(
      'label' =&gt; 'Agent Details',
      'type' =&gt; 'raw',
      'value' =&gt; '',
      'cssClass' =&gt; 'heading',
  ),
  'agent_id',
  'user.email',
  'first_name',
  'last_name',
  'company',
  'phone',
      ),
  )); ?&gt;
  </code></pre>
  
  <p>Any help would be greatly appreicated.</p>
  
  <p>Thanks
  Ab</p>