title: Codeigniter get number of row from search query
body: <p>I have a query in my controller which searches for the term/keyword that is in the url.</p>
  
  <p>Example <code>/search/keyword</code></p>
  
  <p>Then through my controller I perform the search doing:</p>
  
  <pre><code>   $viewdata['search_results'] = 
  $this-&gt;Search_model-&gt;search(strtolower($this-&gt;uri-&gt;segment(2)),$limit,$offset);
  </code></pre>
  
  <p>then I check the database from my model like so:</p>
  
  <pre><code>    function search($searchquery, $limit, $offset) {
  
          $this-&gt;db-&gt;from('content');
          $this-&gt;db-&gt;like('title', $searchquery);
          $this-&gt;db-&gt;or_like('content', $searchquery);
          $query = $this-&gt;db-&gt;limit($limit, $offset)-&gt;get();
  
          $results = Array();
          foreach ($query-&gt;result() as $row) {
  
  
              $results[] = Array(
  
                  'title' =&gt; '&lt;a href="' . base_url() . $row-&gt;anchor_url . ' "&gt;' . strip_tags($row-&gt;title) . '&lt;/a&gt;',
                  'link' =&gt;  base_url() . $row-&gt;anchor_url,
                  'text' =&gt; str_ireplace($searchquery, '&lt;b&gt;' . $searchquery . '&lt;/b&gt;', strip_tags(neatest_trim($row-&gt;content,220,$searchquery,120,120)))
              );
          }
          return $results;
      }
  
  }
  </code></pre>
  
  <p>I would like to know how I can return the number of rows found in my search result to the controller. I will then use the count of rows found for pagination. </p>
  
  <p>How can I get the row count into the controller????</p>