CodeIgniter Forums
Codeigniter Query Builder - finding the number of records from a certain date not wor - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Codeigniter Query Builder - finding the number of records from a certain date not wor (/showthread.php?tid=73345)



Codeigniter Query Builder - finding the number of records from a certain date not wor - spreaderman - 04-13-2019

Within codeigntier, I have the following:

Code:
echo $this->db->where('FROM_UNIXTIME(`last_login`) >=','NOW() - INTERVAL 1 DAY')->from('users')->count_all_results();

The above produces the result: 0

I used print_r($this->db->last_query()); to get the actual sql string being run and it is as follows:

Code:
SELECT COUNT( * ) AS  `numrows`
     FROM  `users`
    WHERE FROM_UNIXTIME(  `last_login` ) >= NOW( ) - INTERVAL 1
    DAY

When I run it from with mysql, I get the correct result: 1.

I am guessing that the escaping is now working or something but cannot figure it out. Any idea?