在codeigniter中,我需要以这种方式使用`count` [英] in codeigniter, I need to use `count` in such a way that
本文介绍了在codeigniter中,我需要以这种方式使用`count`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个查询,该查询获取某些事件的数量。换句话说,我需要一个CodeIgniter方法,以便查询产生类似以下内容的
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
推荐答案
$this->db->select('count(*)');
$this->db->from('comments');
$this->db->where('level','4');
$query = $this->db->get();
echo $query->num_rows();
这篇关于在codeigniter中,我需要以这种方式使用`count`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文