Welcome Guest, Not a member yet? Register   Sign In
Quoting problems with active record
#1

[eluser]nelson.wells[/eluser]
This is a query I found from the MySQL documentation, and it works when I don't do active record queries.

Code:
SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col;

When I try to do this same query with active record, it doesn't work. It looks like the reason is because the date_col column at the end of the field is being enclosed by single quotes like this:

Code:
SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= 'date_col';

How can I write this in active records without the single quotes being generated?
#2

[eluser]JoostV[/eluser]
You can use a custom string as where statement.
Code:
$this->db->where('WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col');
#3

[eluser]nelson.wells[/eluser]
Ah! Thanks, seems so obvious now Smile




Theme © iAndrew 2016 - Forum software by © MyBB