简体   繁体   English

如何在分页库代码点火器中编写Segment

[英]How to write Segment in pagination library code igniter

Mysql Segment ?? Mysql段?? not understood properly in pagination... Here is my code: 在分页中无法正确理解...这是我的代码:

  $data['query']=   $this->db->select('auto_id,title,image,thumb')
                   ->get('gallery',$config['per_page']=12,$this->uri->segment(3));                    

where per_page=12 其中per_page = 12

try to use like this-> 尝试像这样使用->

function records($sort_by = 'rpd_id', $sort_order = 'asc', $offset = 0) {
        $limit = 10;
        $data['results'] = $this->rcbs_Model->get_all_data_from_request($limit, $offset, $sort_by, $sort_order);
        $config = array();
        $config['base_url'] = base_url("rcbs/records/$sort_by/$sort_order");
        $config['total_rows'] = $this->rcbs_Model->count_records();
        $config['per_page'] = $limit;
        $config['uri_segment'] = 5;
        $data['sort_by'] = $sort_by;
        $data['sort_order'] = $sort_order;
        $this->pagination->initialize($config);
        $data['links'] = $this->pagination->create_links();
        $this->load->view('booking_data', $data);
 }

here $sort_by = 'rpd_id' (rpd_id)is the default table column by which data will be sorted. 这里$ sort_by ='rpd_id'(rpd_id)是将对数据进行排序的默认表列。

"get_all_data_from_request" is the function by which you will get all data from your table using select query. “ get_all_data_from_request”是用于使用选择查询从表中获取所有数据的功能。

base_url("rcbs/records/$sort_by/$sort_order"); base_url(“ rcbs / records / $ sort_by / $ sort_order”); rcbs -Controller name 'records'->function name itselft rcbs-控制器名称'records'->函数名称本身

$this->rcbs_Model->count_records() count all the records from the table. $ this-> rcbs_Model-> count_records()计算表中的所有记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM