Reputation: 163
I am working on the codeigniter as a beginner,, and got this problem.. I cannotload the Pagination Library...
Here is the code
<?php
/**
*
*/
class Site extends CI_Controller
{
public function index() {
if($this->load->library('pagination')) {
echo "load success";
}
else {
echo "load failed";
}
$config['base_url'] = 'http://localhost/ci_pagination/index.php/site/index';
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = 10;
$config['num_links'] = 20;
$this->pagination->initialize($config);
echo $this->pagination->create_links();
$data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));
$this->load->view('site_view', $data);
}
}
?>
I even tried autoloading pagination library.. But still it is echoing 'Load Failed' . CAN SOMEBODY HELP ME???????? plzzzzzz
Upvotes: 0
Views: 1030
Reputation: 8385
You need to check your code, load function does not return boolean value (it returns NULL or error), therefore your if()
statement is always false
, in fact you can check in CodeIgniter logs after you turn on log_threshold
config value to 2
- DEBUG.
It looks like this:
DEBUG - 2015-01-11 16:51:11 --> Pagination Class Initialized
testing code I am working with:
public function pagination() {
var_dump( $this->load->library('pagination') );
}
Further more you want this line in your view file instead of controller itself.
echo $this->pagination->create_links();
Please do your homework before asking here next time.
Upvotes: 1