我试图......
这是我最初的尝试:
$this->db->select(<aggregation, subqueries>);
$this->db->from('users');
$this->db->where(<complex filters>);
$total = $this->db->count_all_results();
$this->db->limit($limit, $offset);
$query = $this->db->get();
$result = $query->result();
但是在内部调用count_all_results
调用_reset_select
意味着我必须再次执行第一步 - 不是非常干。
您将如何以简单,干净的方式实现这一目标?
答案 0 :(得分:0)
只需使用查询生成器缓存
$this->db->start_cache();
$this->db->select(<aggregation, subqueries>);
$this->db->from('users');
$this->db->where(<complex filters>);
$this->db->stop_cache();
$total = $this->db->count_all_results();
$this->db->limit($limit, $offset);
$query = $this->db->get();
$this->db->flush_cache();
$result = $query->result();