Welcome Guest, Not a member yet? Register   Sign In
Specific query not working with Active Record Class and row grouping
#6

[eluser]Dandy_andy[/eluser]
Can't figure this one out. I'm guessing this is Codeigniter's limitation? I have managed to do what I need to do using a direct query but a bit disappointed that the Active Record Class will only do very basic queries.

Code:
$query = $this->db->query('
   SELECT x.*, y.mem_id, y.screenname, y.last_activity_date
   FROM (SELECT messages.* FROM messages ORDER BY datetime DESC) AS x
   JOIN members AS y ON x.to_mem_id = y.mem_id
   WHERE (from_mem_id = '.$this->session->userdata('mem_id').')
   GROUP BY x.to_mem_id');
$this->db->limit($limit, $pgn);
return $query->result_array();


Messages In This Thread
Specific query not working with Active Record Class and row grouping - by El Forum - 06-23-2014, 01:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB