码迷,mamicode.com
首页 > 其他好文 > 详细

codeigniter 使用

时间:2018-07-09 11:07:06      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:用法   需要   guide   log   from   rom   tom   uri   ati   

CodeIgniter系列 记录count和分页

对于某个表的不带条件的count,可以简单的用

$total = $this->db->count_all($table_name)

来获取,但是如果有条件,则要用count_all_results

$this->db->where(‘sex‘, ‘M‘);

$this->db->from(‘user‘);

$total = $this->db->count_all_results();

 

CI的pagination库可以帮助添加分页链接,用法可以看user_guide/libraries/pagination.html

有几点需要说明。

base_url里边如果有超过2个uri_segments,则需要设置$config[‘uri_segment‘] = base_url_segments + 1

也就是uri_segment默认是3。如果不设置的话,第一页和前一页,后一页的链接都不正确。

文章标签: user urltable 

codeigniter 使用

标签:用法   需要   guide   log   from   rom   tom   uri   ati   

原文地址:https://www.cnblogs.com/andydao/p/9282173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!