title: Fetch data in every 5 second in Codeigniter
body: <p>How can I run a query to fetch data every 5 second in codieginiter?</p>
  
  <p>My query is: </p>
  
  <pre><code>    $this-&gt;db-&gt;order_by('added_on', 'DESC');
      $this-&gt;db-&gt;limit('50');
      if($from_date == '' &amp;&amp; $to_date == '')
          $where = ('(status = "'.pending.'" or status = "'.error.'")');
      else
          $where = "DATE_FORMAT(added_on,'%Y-%m-%d') &gt;='".$from_date."'AND DATE_FORMAT(added_on,'%Y-%m-%d')&lt;='".$to_date."' AND (status='error' OR status='pending')";
      $query = $this-&gt;db-&gt;get_where('cp_purchase_transaction_history',$where);
      //echo $this-&gt;db-&gt;last_query();die;
  </code></pre>