• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination - Am I Missing something about per_page?

#2
[eluser]Twisted1919[/eluser]
Why initialize the pagination in the model ? This isn't a good practice at all(my opinion)
if i where you , in my model i would just execute the query with the limit and the offset , then i would generate the pagination in my controller .
For instance :
Code:
$items = $this->model->count_items();
$per_page = 10 ;
$segment = (int)$this->uri->total_segments() ;

if( $items <= $per_page )
{
$data['pagination'] = 'Page 1 of 1';
$data['items'] = $this->model->get_items(0,$per_page);
}
else
{
$this->load->library('pagination');
//Pagination config here //
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['items'] = $this->model->get_items($segment,$per_page);
}


Messages In This Thread
Pagination - Am I Missing something about per_page? - by El Forum - 01-01-2010, 03:31 PM
Pagination - Am I Missing something about per_page? - by El Forum - 01-01-2010, 04:29 PM
Pagination - Am I Missing something about per_page? - by El Forum - 01-01-2010, 05:27 PM
Pagination - Am I Missing something about per_page? - by El Forum - 01-01-2010, 11:50 PM
Pagination - Am I Missing something about per_page? - by El Forum - 01-02-2010, 05:18 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.