简体   繁体   中英

Which is the best pagination for displaying mysql records

I have an application where users fetch records for reporting purpose. But i'm confused between using jquery pagination and mysql pagination (LIMIT, OFFSET).

Because jquery pagination needs all records without limit so that pagination takes place at client side and this may slow down the query.

Where mysql can use limit (i'm using codeigniter framework) but every time i click on pagination it will ping for database for getting next set of data and also mysql pagination is creating duplicate records.

Is there a good and fast way to pagination, If yes, Please suggest me.

Thank You......

I did pagination in this way......

public function page($category_id)
{

$result = $this->model_file->model_function($category_id);

$start_index = 0;

$total_rows = count($result);

$items_per_page = 10;

$filtered = array_splice($result,$start_index,$items_per_page);

$model['data'] = $filtered;

$model['page_link'] = create_page_links (base_url()."/controller_file_name/page", $items_per_page, $total_rows);

$this->load->view('view_file_name_path',$model);

}

function create_page_links($base_url, $per_page, $total_rows) {

$CI = & get_instance();
$CI->load->library('pagination');

$config['base_url'] = $base_url;
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page; 

$CI->pagination->initialize($config); 

return $CI->pagination->create_links();

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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