• CI框架分页类


    分页类
    1.分页类参数说明
    'base_url' => 指向你的分页所在的控制器类/方法的完整的 URL,
    'total_rows' => 数据的总行数,
    'per_page' => 每页显示的项目,
    'uri_segment' => 自动检测哪一段包含页数,
    'num_links' => 放在当前页前后显示的链接数,

    2.分页类使用
    $this->load->library('pagination');//加载分页类
    $this->load->helpers('config_pagination');//使用配置项参数
    $cfg = config_pagination($url, $count, $per_page, 4);//base_url , total_rows , per_page ,uri_segment
    $this->pagination->initialize($cfg);//初始化分页类
    $this->pagination->create_links();//在视图中显示

    3.分页类技巧
    使用参数表示 列表 和 单条 两个不同类型,
    查询对应的总数,uri_segment使用同一个分页类

    4.完整的分页类代码
    public function lists($type = '', $start = 0)
    {

    $s = trim($this->input->get('s'));
    $data['s'] = $s;
    $per_page = 20;
    if ($type == 'search') {
    $content = $this->suits_model->getRowsBytype($s, $start, $per_page);
    $count = $content['count'];
    $url = "/admin/suits/lists/$type";
    } else {
    $start = $type;
    $content = $this->suits_model->getRowsByALL($start, $per_page);
    $count = $content['count'];
    $url = "/admin/suits/lists/";
    }
    $options = $this->suitstypes_model->getRows();
    //分页
    $this->load->library('pagination');
    $this->load->helpers('config_pagination');
    $cfg = config_pagination($url, $count, $per_page, 4);
    $this->pagination->initialize($cfg);
    $data['state_button'] =$this->state_button;
    $data['pages_html'] = $this->pagination->create_links();
    $data['count'] = $count;
    $data['content'] = $content['content'];
    $data['title'] = '包装列表';
    $data['user'] = $this->user;
    $data['options'] = $options['query']->result_array();
    $data['base_url'] = $this->base_url;
    $this->load->view('admin/header', $data);
    $this->load->view('admin/suits_lists');
    $this->load->view('admin/footer');
    }

  • 相关阅读:
    Request源码总结
    jmeter并发顺序问题
    mysql函数应用
    读《飘》之后的感受
    itchat源码阅读一
    python将print的内容输出到txt文件
    说一下StoreBoard和纯代码编程各有什么好处吧
    CocoaPods 安装
    Silverlight调用WebSite类型的WebService,Debug时的跨域问题
    ComboBox的奇怪属性
  • 原文地址:https://www.cnblogs.com/zc123/p/5403463.html
Copyright © 2020-2023  润新知