用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1568|回复: 4
收起左侧

[分页] CI分页total_rows支取一些值

[复制链接]
发表于 2017-4-13 10:36:56 | 显示全部楼层 |阅读模式
我在我的页面代码是这样的$config['total_rows'] = $this->db->count_all_results('exam_guanli');,这样统计的是数据库中所有的数据,请问如果我经过一个方法查询出来的数据是两条甚至更多,我先想用这个数量做个分页,而不是所有,应该用用什么方法呢
发表于 2017-4-13 10:54:36 | 显示全部楼层
仔细看这里 http://codeigniter.org.cn/user_g ... ry_builder.html#id6 ,是可以给一个 where 条件的。

点评

谢谢谢  发表于 2017-4-13 11:06
 楼主| 发表于 2017-4-13 11:17:54 | 显示全部楼层
Hex 发表于 2017-4-13 10:54
仔细看这里 http://codeigniter.org.cn/user_guide/database/query_builder.html#id6 ,是可以给一个 where ...

他这里where怎么使用啊$config['total_rows'] = $this->db->where(..)->from();嘛,这样不就没有count_all_results,count_all_results()里面第二值还得是FLASE
发表于 2017-4-13 14:25:46 | 显示全部楼层
j897011372 发表于 2017-4-13 11:17
他这里where怎么使用啊$config['total_rows'] = $this->db->where(..)->from();嘛,这样不就没有count_a ...

这里不是有一个例子么?
PHP复制代码
 
$this->db->where('title', 'match');
$this->db->from('my_table');
echo $this->db->count_all_results(); // Produces an integer, like 17
 
复制代码

本版积分规则