最新下载
热门教程
- 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.1*11*cn*n.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); } |
|
相关文章
- 整理拾光全部隐藏物品获取方法攻略 12-04
- 魔理沙还书姬虫百百世彩蛋位置一览 12-04
- 阿西美女室友竟然2第六章全流程攻略 12-04
- 超英派遣中心第四章第一轮班派遣攻略 12-04
- 阿西美女室友竟然2第五章全流程攻略 12-04
- 梦之形跳跳锤维斯珀玩法攻略分享 12-04