madwolfs 发表于 2009-11-7 22:43:06

ci中DB有个count_all方法

这个方法可以设置 where 条件嘛
我今天自己写了个count方法:第一个参 为表名, 第二个参数为 where 语句。


呵呵

madwolfs 发表于 2009-11-7 22:43:27

CI框架很强大,大家多交流哈

Hex 发表于 2009-11-7 22:55:12

只有 $this->db->count_all_results(); 可以加条件,也就是 AR 里的方法才可以加条件。
请仔细看手册。

heiniu 发表于 2009-11-8 22:42:23

$this->db->like('title', 'match');
$this->db->from('my_table');
echo $this->db->count_all_results();

幽蓝冰魄 发表于 2010-8-9 14:43:21

可不可以在view中用num_row来赋值?

ttyangz 发表于 2010-8-16 20:59:32

$config['total_rows'] = $this->MStudent->serchStudents($_POST)->num_rows();

kevin50ster 发表于 2010-8-26 23:39:16

我是先get_where来获得需要的行数,再用num_rows()取得需要的结果,这样能实现,不过效率上可能会低了一点
页: [1]
查看完整版本: ci中DB有个count_all方法