最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Codeigniter框架实现获取分页数据和总条数
时间:2022-06-25 00:57:36 编辑:袖梨 来源:一聚教程网
代码如下 | 复制代码 |
/** * 获取分页数据及总条数 * @param string @tablename 表名 * @param mixed $where 条件 * @param int $limit 每页条数 * @param int $offset 当前页 * * @link http://www.111cnn.net |
代码如下 | 复制代码 |
*/ public function get_page_data($tablename, $where, $limit, $offset, $order_by, $db) { if(empty($tablename)) { return FALSE; } $dbhandle = empty($db) ? $this->db : $db; if($where) { if(is_array($where)) { $dbhandle->where($where); } else { $dbhandle->where($where, NULL, false); } } $db = clone($dbhandle); $total = $dbhandle->count_all_results($tablename); if($limit) { $db->limit($limit); } if($offset) { $db->offset($offset); } if($order_by) { $db->order_by($order_by); } $data = $db->get($tablename)->result_array(); return array('total' => $total, 'data' => $data); } |
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16