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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -