Postingan lainnya
Gimana cara select sum berdasarkan isi field
gan ane mau jumlahin user yang punya role id = 2 dia itu member nah gimana ya queryny?
$this->db->select_sum('roleId');
$query = $this->db->get('user');
if ($query->num_rows() > 0) {
return $query->row()->roleId;
} else {
return 0;
}
0
1 Jawaban:
Cek di dokumentasi resmi codeigniter, <a href='https://codeigniter.com/userguide3/database/query_builder.html#limiting-or-counting-results'>count di codeigniter</a>
<pre> $this->db->like('title', 'match'); $this->db->from('my_table'); echo $this->db->count_all_results(); </pre>
0