Hey I have the following problem:
I have a very long MySQL query, and then I want to count rows which it returns.
After getting this result I want to make it again with some limit and group my results by one of columns.
So it looks that:
/*
query conditions....
query conditions....
query conditions....
query conditions....
query conditions....
query conditions....
query conditions....
*/
//first query
$query = $this->db->get();
$results = $query->result_array();
$this->db->select("FOUND_ROWS() as cnt");
$cnt_array = $this->db->get()->row_array(); //here is my number of rows
//second query and if instruction
if($sth==0) { $this->db->group_by(...);}
$this->db->limit($count, $from);
$query = $this->db->get();
$results = $query->result_array();
$this->db->select("FOUND_ROWS() as cnt");
$tot_cnt = $this->db->get()->row_array(); //now i want to have number of grouped results.
but the second query doesnt work, how to do it?