ねえ、私は次の問題を抱えています:
非常に長いMySQLクエリがあり、それが返す行をカウントしたいと思います。
この結果を取得した後、制限を付けて再度作成し、結果を列の1つでグループ化します。
したがって、次のようになります。
/*
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.
しかし、2番目のクエリは機能しません。どうすればよいですか?