Welcome Guest, Not a member yet? Register   Sign In
How does the pagination class work?
#1

[eluser]zxcv[/eluser]
Hello!
I'm wondering how the pagination class works.
My code is similiar to this:


CONTROLLER
Code:
class Books extends Controller {
  function __construct() {
    parent::Controller();
    $this->load->helper('url');
    $this->load->database();
  }

  function index() {
    // load pagination class
    $this->load->library('pagination');
    $config['base_url'] = base_url().'index.php/books/index/';
    $config['total_rows'] = $this->db->count_all('christian_books');
    $config['per_page'] = '5';
    $config['full_tag_open'] = '<p>';
    $config['full_tag_close'] = '</p>';

    $this->pagination->initialize($config);
        
    //load the model and get results
    $this->load->model('books_model');
    $data['results'] = $this->books_model->get_books($config['per_page'],$this->uri->segment(3));
        
    // load the HTML Table Class
    $this->load->library('table');
    $this->table->set_heading('ID', 'Title', 'Author', 'Description');
        
    // load the view
    $this->load->view('books_view', $data);
  }
}

MODEL
Code:
class books_model extends Model {
  function __construct(){
    parent::Model();
  }

  function get_books($num, $offset) {
    $query = $this->db->get('christian_books', $num, $offset);    
    return $query;
  }
}


The view just makes the table and the pagination links.

I am wondering how "the flow of the pagination" is going here? Does a click on an pagination link call a new mysql query?


Messages In This Thread
How does the pagination class work? - by El Forum - 08-03-2011, 04:44 AM
How does the pagination class work? - by El Forum - 08-03-2011, 05:51 AM
How does the pagination class work? - by El Forum - 08-03-2011, 05:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB