active record summation in codeigniter active record summation in codeigniter codeigniter codeigniter

active record summation in codeigniter


That should do the trick:

$this->db->select('SUM(type) as score');$this->db->where('question_id',1);$q=$this->db->get('votes');$row=$q->row();$score=$row->score

Your $score variable now contains the sum of the types for that particular question.

Hope that helps!