计数结果由Codeigniter中的distinct()或group_by()过滤

bau*_*usa 4 php database postgresql codeigniter

我想用CI计算我的活动记录查询结果(使用postgreSQL).我正在使用count_all_results(),它适用于大多数查询,但不能在使用时distinct()group_by()在连接后使用,因为count_all_results()忽略这些功能.

这是一个修复版本,它尚未在newsest(2.1.3)稳定版本中实现. https://github.com/EllisLab/CodeIgniter/commit/b05f506daba5dc954fc8bcae76b4a5f97a7433c1

当我尝试在当前版本中尝试实现此修复时,没有进行额外的过滤.行数保持不变.

有关如何在当前版本中实现此功能的任何提示,或其他计算过滤结果的方法distinct()group_by()

its*_*sme 7

    $this->db->select('COUNT(id)');
    $this->db->join();
    $this->db->distinct();
    $this->db->group_by();
//...etc ...
    $query = $this->db->get('mytable');

    return count($query->result()); 
Run Code Online (Sandbox Code Playgroud)

要么

    $this->db->join();
    $this->db->distinct();
    $this->db->group_by();
//...etc ...
    $query = $this->db->get('mytable');

    return $query->num_rows(); 
Run Code Online (Sandbox Code Playgroud)