title: Yii framework pagination problem with MySQL FOUND_ROWS
body: <p>I am trying to implement pagination in my search results with Yii.  I have pagination working on my browse record pages, but for some reason, am having trouble with getting it working in search.  </p>
  
  <p>So far, I have the following SQL to produce the search results:</p>
  
  <pre><code>SELECT SQL_CALC_FOUND_ROWS DISTINCT user.id FROM user, personal_info WHERE (personal_info.bio LIKE '%a%' ) AND personal_info.user_id = user.id AND user.role = 'F' LIMIT 0, 8;
  </code></pre>
  
  <p>Which is passed to ActiveRecord as follows:</p>
  
  <pre><code>$results = $this-&gt;findAllBySql($sql);
  </code></pre>
  
  <p>Immediately afterwards I run this code:</p>
  
  <pre><code>$rows = $this-&gt;findBySql("SELECT FOUND_ROWS() as row_count;");  
  echo $rows-&gt;row_count;
  </code></pre>
  
  <p>Strangely, I am receiving the following error when I try and execute the above code:</p>
  
  <p>Property "Search.row_count" is not defined.</p>
  
  <p>For some reason, Yii is not able to retrieve the FOUND_ROWS value from MySQL.</p>
  
  <p>I have pretty much exactly the same PHP code in my browse records page (but different SQL), and it works perfectly.  Not sure why in this situation Yii is unable to retrieve the FOUND_ROWS value.  I've tried running this code directly inside MySQL to see if there was something wrong with my SQL, but it retrieves the FOUND_ROWS value with no problems - this problem only happens when I try to do it inside Yii.</p>
  
  <p>Any idea what I maybe doing wrong?</p>
  
  <p>Many thanks!</p>