How to Paginate Joined Table Results? - El Forum - 08-13-2010
[eluser]Corey Freeman[/eluser]
I'm using the ajax pagination library, by the way.
I have joined table results to get the updates from a user and their data. I dunno how to work that with pagination though...
Code: ///////////////////////////////////////////////////////////
$support_id = $this->session->userdata('id');
$data['feed'] = $this->db
->select('goals.goal, goals.goal_id, goals.description, users.id, users.username, users.avatar')
->from('goals')
->join('supporters', 'supporters.user_id = goals.user_id')
->where('supporters.support_id',$support_id)
->join('users', 'supporters.user_id = users.id')
->orderby('goals.goal_id', 'DESC')
->get();
///////////////////////////////////////////////////////////
Help would be much appreciated.
How to Paginate Joined Table Results? - El Forum - 08-29-2010
[eluser]Corey Freeman[/eluser]
I could really use some help with this
Code: ///////////////////////////////////////////////////////////
$support_id = $this->session->userdata('id');
$this->db->where('user_id', $support_id);
$this->db->where('complete', 0);
$this->load->model('goal_model');
$total = $this->goal_model->count_goals();
$per_page = 5;
$config['base_url'] = site_url('dashboard/friends/2');
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$config['div'] = 'body';
$config['uri_segment'] = '4';
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
//Previous
$config['prev_link'] = 'Previous';
$config['prev_tag_open'] = '<span class="prev">';
$config['prev_tag_close'] = '</span>';
//Next
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<span class="next">';
$config['next_tag_close'] = '</span>';
$this->jquery_pagination->initialize($config);
$this->db
->select('goals.goal, goals.goal_id, goals.description, users.id, users.username, users.avatar')
->from('goals');
->join('supporters', 'supporters.user_id = goals.user_id')
->where('supporters.support_id',$support_id)
->join('users', 'supporters.user_id = users.id');
$this->db->order_by("goal_id", "desc");
$this->db->where('user_id', $support_id);
$data['feed'] = $this->goal_model->get_goals($per_page, $this->uri->segment(4));
Not really sure how to cobble it together.
How to Paginate Joined Table Results? - El Forum - 08-29-2010
[eluser]Corey Freeman[/eluser]
Nevermind. The problem was with my models, not the controller.
|