title: Mysql query return empty result in Codeigniter but working fine in native PHP
body: <p>I can't figure out why my query always return empty result in Codeigniter. The same query is works as expected when run in SQL box in phpmyadmin. </p>
  
  <p>My table (users) look something like this: </p>
  
  <pre><code>id | name        | registration
  -------------------------------
   1 | John        | 2016-06-09 12:00:08
   2 | Mike        | 2016-06-12 12:45:23
   3 | Greg        | 2016-06-13 11:50:05
   4 | Anthony     | 2016-06-14 02:34:08
   5 | Adam        | 2016-06-14 04:34:18
   6 | Steven      | 2016-06-15 13:55:34
   7 | Joe         | 2016-06-16 07:23:45
   8 | David       | 2016-06-17 06:19:31
   9 | Richard     | 2016-06-17 11:20:27
  10 | Jack        | 2016-06-17 12:00:08
  </code></pre>
  
  <p>and so on. I just want to get a list of all people whose registration date is in the last 7 days. 'registration' column is of DATETIME type </p>
  
  <p>Here's my code in CI model using Query Builder. Already autoload database library</p>
  
  <pre><code>   function get_user()
     {
      $query = $this-&gt;db-&gt;select('name')
                    -&gt;where('registration','BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()')
                    -&gt;get('users');
      return $query-&gt;result();
     }
  </code></pre>
  
  <p>It's return empty result without error. Next I try to put query directly like this</p>
  
  <pre><code>    function get_user()
      {
       $query = $this-&gt;db&gt;query('SELECT name FROM users WHERE registration BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()');
      return $query-&gt;result();       
      }
  </code></pre>
  
  <p>Also return empty result without error. So out of curiosity I tried to run the same query using native PHP outside Codeigniter. Here's the code :</p>
  
  <pre><code>   &lt;?php
     $link = mysqli_connect("localhost", "myusername", "mypassword", "mydatabase");
  
     if (mysqli_connect_errno()) {
     printf("Connect failed: %s\n", mysqli_connect_error());
     exit();
     }
  
     $query = "SELECT name FROM users WHERE registration BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()";
     $result = mysqli_query($link, $query);
     while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
     echo $row["name"];
     echo "&lt;br&gt;";
     }
  
     mysqli_free_result($result);
     mysqli_close($link);
     ?&gt;
  </code></pre>
  
  <p>And voila...it works and return result as expected. So any idea what's the problem with Codeigniter in this case? Any input will be appreciated. Thanks all</p>