title: Codeigniter number of rows in controller
body: <p>I have a model where I select the proper data from database as below:</p>
  
  <pre><code>&lt;?php
      class vacancies extends CI_Model{
  
          function vacancies()
          {
              $query = $this-&gt;db-&gt;query("SELECT * FROM ecc_vacancies_vac WHERE active_vac = 1 AND end_vac &gt;= CURDATE() ORDER BY date_vac DESC");
  
              if($query-&gt;num_rows() &gt;= 1){
                  foreach($query-&gt;result() as $row){
                      $data[] = $row;
                  }
                  return $data;
              }
          }
  
      }  
  </code></pre>
  
  <p>and a controller to handle this data before sending to view as below:               </p>
  
  <pre><code>function index()
  {
      //check if there any available vacancies
  
      $this-&gt;load-&gt;model('vacancies');
      $data['vacancies'] = $this-&gt;vacancies-&gt;vacancies();
      // then i load the views here 
   }
  </code></pre>
  
  <p>What I need to do, is to know the total number of returned rows here in the controller so I can send the number to the view to use it later.</p>
  
  <p>When using active records I used to use this line of code:</p>
  
  <pre><code>$data['num_rows'] = $$data['vacancies']-&gt;num_rows();
  </code></pre>
  
  <p>How can I define it in my case?</p>