in codeigniter, I need to use `count` in such a way that

codeigniter, mysql

Solution

$this->db->select('count(*)');
$this->db->from('comments');
$this->db->where('level','4');
$query = $this->db->get();
echo $query->num_rows();

Problem

I need a query that gets number of some occurrences. In other words, I need a CodeIgniter method such that query produces something like: ``` SELECT COUNT( * ) AS total FROM comments WHERE `level`= 4 ```

Original source