i am using codeigniter active records to execute a simple mysql query to select data in last one hour.
so my query is:
SELECT * FROM tablename WHERE added_datetime >= DATE_SUB(NOW(),INTERVAL 1 HOUR)
and my codeigniter code to form this query is:
$data=array(
'added_datetime >='=>'DATE_SUB(NOW(),INTERVAL 1 HOUR)',
);
$query=$this->db->get_where('tablename',$data);
now the issue is codeigniter adds a single quotes around the DATE_SUB function and due to this the query not works on mysql server.
codeigniter produces:
SELECT * FROM (`tablename`) WHERE `added_datetime` >= 'DATE_SUB(NOW(),INTERVAL 1 HOUR)'
i also tried by adding FALSE
as 3rd parameter in get_where
but stil not worked
$query=$this->db->get_where('tablename',$data,FALSE);
it also produced the same query as above. So please suggest me how to solve this issue.
-Thanks