CodeIgniter Forums
SQL CURDATE() in activerecords where clause - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: SQL CURDATE() in activerecords where clause (/showthread.php?tid=51896)



SQL CURDATE() in activerecords where clause - El Forum - 05-22-2012

[eluser]florin[/eluser]
how do you put SQL functions like CURDATE() in active records Where clause to compare
I have a date field in mysql named "data" and i need to select the records that have data> curent data. It seems that $this->db->where('data >',CURDATE()) is not working . Tks mates !


SQL CURDATE() in activerecords where clause - El Forum - 05-22-2012

[eluser]Silviu[/eluser]
This is from the User Guide:

Quote:$this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.

Code:
$this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);

So your query should look like this:
Code:
$this->db->where('`data` > CURDATE()',NULL,FALSE);
or like this:
Code:
$this->db->where('`data` >','CURDATE()',FALSE);

Pick your poison Smile


SQL CURDATE() in activerecords where clause - El Forum - 05-22-2012

[eluser]florin[/eluser]
Take you !