php - Counting results filtered by distinct() or group_by() in Codeigniter -


i want count results of active record query ci (using postgresql). using count_all_results(), works fine queries, not when using distinct() or group_by() after join, because count_all_results() ignores these functions.

here fix vor this, not yet implemented in newsest (2.1.3) stable version. https://github.com/ellislab/codeigniter/commit/b05f506daba5dc954fc8bcae76b4a5f97a7433c1

when try implement fix in current version myself, there no additional filtering done. row count stays same.

any tips on how implement in current version, or other ways count results filtered distinct() or group_by()?

    $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());  

or

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

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -