最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Codeigniter框架实现获取分页数据和总条数
时间:2014-04-03 编辑:简简单单 来源:一聚教程网
代码如下 | 复制代码 |
/** * 获取分页数据及总条数 * @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); } |
-
上一个: python遍历目录的例子(不用递归)
-
下一个: wxpython怎么设置背景?
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24