title: Getting result from a query in a function and count the num_rows in Codeigniter
body: <p>My query in model :</p>
  
  <pre><code>public function infoReprob(){
      $tid = $this-&gt;input-&gt;get('tid');
      $query = $this-&gt;db-&gt;select('histprob.tid,histprob.ketprob,histprob.updated_at,otslm.lokasi')-&gt;from('histprob')-&gt;join('otslm', 'otslm.tid = histprob.tid')-&gt;where('histprob.tid', $tid)-&gt;get();
      return $query-&gt;result();
   }
  </code></pre>
  
  <p>Above query is used to result and work perfectly in a view in Ajax. But I need to count the result also, and I am trying to use the folowong in Controller :</p>
  
  <pre><code>function index(){
      $data['reprobs'] = count($this-&gt;m-&gt;infoReprob()); // USING COUNT
      $this-&gt;load-&gt;view('front/reprob_view', $data);
  }
  </code></pre>
  
  <p>And call the variable inside my Javascript like :</p>
  
  <pre><code>&lt;?php echo $reprobs; ?&gt;
  </code></pre>
  
  <p>But it results : 0, even the actual num_rows is > 0.</p>
  
  <p>Please help solve this.. Thank you so much</p>