[eluser]cpass78[/eluser]
OK Im stumped...
For some stupid reason i can't get the links to show in my view and i spent more time on it then i like so I'm turning to the community for assistance.
Controller code
Code:
public function listTodos() {
$this -> load -> library('pagination');
$this -> load -> library('table');
$this -> table -> set_template(array('table_open' => '<table class="zebra-striped">'));
$this -> data['content'] = 'view_todos';
$config['base_url'] = site_url('my_account/listtodos');
$config['per_page'] = 5;
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$todos = $this -> crud_model -> listTados($this -> userid, $this -> orderby, $this -> sort, $config['per_page'], $page);
echo $config['total_rows'] = count($todos); //prints out 5 correctly out of 9 records
$this->data['paginate'] = $this -> pagination -> create_links();
$this -> pagination -> initialize($config);
//$this->data ['category'] = $category;
$this -> data['todos'] = $todos;
$this -> load -> view($this -> template . 'backend/template', $this -> data);
}
Model code
Code:
function listTados($userid, $orderby, $sort, $limit, $offset) {
$query = $this -> db -> where('user_id', $userid) -> order_by($orderby, $sort) -> limit($limit, $offset) -> get('******');
if ($query -> num_rows > 0) {
return $query -> result();
}
return false;
}
In my view i echo out $paginate, all pretty easy stuff right..
The strange thing is that in profiler my query looks like so
Code:
SELECT *
FROM (`******`)
WHERE `user_id` = '1'
ORDER BY `id`
LIMIT 5
The offset is not getting passed unless i switch the vars passed to the model but then i only get one record returned and the offset is shown.
Any clues?
Thank you