title: How to Store result of a HAS_MANY RELATION database query in yii?
body: <p>PLEASE HELP....I AM A NEWBIE</p>
  
  <p>I have 2 tables <strong>PAGE</strong> and <strong>COMMENT.</strong></p>
  
  <p><strong>Page</strong> table has columns</p>
  
  <pre><code>$id
  $user_id 
  $content
  </code></pre>
  
  <p><strong>Comment</strong> table has columns</p>
  
  <pre><code>$id
  $user_id
  $page_id
  $date_entered
  
  $comment      **The comment column consist of an array of comments as one user can have many comments** 
  </code></pre>
  
  <p>In the Page model the relation in the relation() is defined as</p>
  
  <pre><code>return array(
      'comments' =&gt; array(self::HAS_MANY, 'Comment', 'page_id')
  )
  </code></pre>
  
  <p>Now in the PageControllor.php,I have defined this query in the actionView()</p>
  
  <pre><code>$page = Page::model()-&gt;with('user','comments')-&gt;findByPk($id);
  </code></pre>
  
  <p>Now my question is</p>
  
  <p>how can i get the result of this query in <strong>$result</strong> so that i could pass it to the view page as</p>
  
  <pre><code>$this-&gt;render('view',array('model'=&gt;$this-&gt;loadModel($id),'result'=&gt;$result))
  </code></pre>