Reputation: 1606
I am using Codeingiter's active record and need to check for entries that are less than 15 minutes old.
I have tried the following, which I thought would work.
$this->EE->db->select('entry_id')
->from('exp_channel_titles')
->where('status', $status)
->where('channel_id', $channel)
->where(FROM_UNIXTIME('entry_date') >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE))
->order_by('entry_date', 'desc');
Does anyone know if its possible to do this?
I had hoped this would do work in a where clause"
FROM_UNIXTIME('entry_date') >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE)
Upvotes: 1
Views: 101
Reputation: 35337
From https://ellislab.com/codeigniter/user-guide/database/active_record.html:
$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.
$this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);
So you should be able to pass a string like:
->where('FROM_UNIXTIME(`entry_date`) >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE)', NULL, FALSE)
Upvotes: 2