CodeIgniter Forums

Full Version: Pagination with joined table
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Wonder Woman[/eluser]
Hi

I had my pagination working but then the structure of the database changed so it now doesn't work because I have to join two tables to get the results I once had...

My db script is:

Code:
$query = $this->db->select('*');
$query = $this->db->from('user_entry');
$query = $this->db->join('user_details', 'user_entry.UserID = user_details.id');
$query = $this->db->limit($limit, $offset);
$query = $this->db->get();

If you could help me, I would be so grateful - thanks.

El Forum

[eluser]Cristian Gilè[/eluser]
This is the right way to write the query:

Code:
$query = $this->db->select('*')
                  ->from('user_entry')
                  ->join('user_details', 'user_entry.UserID = user_details.id')
                  ->limit($limit, $offset)
                  ->get();

We can't do much to help you only with the query code.


Cristian Gilè