Welcome Guest, Not a member yet? Register   Sign In
SQL CURDATE() in activerecords where clause
#1

[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 !
#2

[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
#3

[eluser]florin[/eluser]
Take you !




Theme © iAndrew 2016 - Forum software by © MyBB