Reputation: 1743
I have a database table with separate date and time column. To get particular I execute query in mysql in following manner
select * from table_A where empID='A1201' order by TIMESTAMP(date,time) desc limit 1
How can I convert this particular for codeigniter? I tried in following manner but it's not working
$column = 'TIMESTAMP(date,time)';
$this->db->select('*');
$this->db->where('empID', 'A1201');
$this->db->from('table_A');
$this->db->order_by($column, 'desc');
$this->db->limit(1);
$query = $this->db->get();
$data = $query->result();
return $data;
This query result in error since it executes in following manner ORDER BY TIMESTAMP(date DESC, time) DESC
while the correct way is ORDER BY TIMESTAMP(date,time) DESC
. What will be the correct way for codeigniter using active record
Upvotes: 0
Views: 328