public function index()
 {
     $status = I('status', 0);
     $keyword = I('keyword', '');
     $list = array();
     $where = array();
     if ($status) {
         $where['status'] = $status;
     }
     $this->assign('status', $status);
     if ($keyword) {
         $where['adminname'] = array('like', "%{$keyword}%");
     }
     $this->assign('keyword', $keyword);
     $model = D('Admin');
     $count = $model->where($where)->count();
     // 查询满足要求的总记录数
     $page = new \Admin\Org\Page($count, $this->page_num);
     // 实例化分页类 传入总记录数和每页显示的记录数
     // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
     $order = 'id asc';
     $list = $model->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select();
     $show = $page->pageShow();
     // 分页显示输出
     $this->assign('list', $list);
     // 赋值数据集
     $this->assign('page', $show);
     // 赋值分页输出
     $this->display();
     // 输出模板
 }
 public function role_list()
 {
     $status = I('status', -1);
     $search_id = I('search_id', 0, 'intval');
     $search_name = I('search_name', '');
     $order = I('order', 0);
     // 排序 0:降序 1:升序
     $where = array();
     // 按状态
     if ($status == 0) {
         $where['status'] = 0;
     } else {
         if ($status == 1) {
             $where['status'] = 1;
         } else {
             $where['status'] = array('in', array(0, 1));
         }
     }
     $this->assign('status', $status);
     // 按id搜索
     if ($search_id) {
         $where['id'] = $search_id;
         // 将变量再分配到模板中
         $this->assign('search_id', $search_id);
     }
     // 按名称搜索
     if ($search_name) {
         $where['name'] = array('like', "%{$search_name}%");
         // 将变量再分配到模板中
         $this->assign('search_name', $search_name);
     }
     // 排序
     if ($order == 1) {
         $order = 'id ASC';
         $this->assign('order', 0);
     } else {
         $order = 'id DESC';
         $this->assign('order', 1);
     }
     $model = D('Role');
     $count = $model->where($where)->count();
     // 查询满足要求的总记录数
     $page = new \Admin\Org\Page($count, $this->page_num);
     // 实例化分页类 传入总记录数和每页显示的记录数
     // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
     $order = 'id asc';
     $list = $model->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select();
     $show = $page->pageShow();
     // 分页显示输出
     $this->assign('list', $list);
     $this->assign('page', $show);
     $this->display();
 }