Welcome Guest, Not a member yet? Register   Sign In
Problem with multiple joins
#1

[eluser]JoshK[/eluser]
I'm new to Code Igniter, and so far love it. However, I'm having issues when using multiple join statements in my functions.

Example: this code doesn't work.

Code:
function get_records()
    {
        $this->db->from('events');
        $this->db->join('event_dates', 'event_dates.event_id = events.event_dates', 'LEFT');        
        $this->db->join('locations', 'locations.location_id = events.event_location', 'LEFT');
        $this->db->join('users', 'users.user_id = events.event_creator', 'LEFT');
        $this->db->join('categories', 'categories.category_id = events.event_category', 'LEFT');

        
        $query = $this->db->get();
        
        return $query->result();
    }

however, if I only have 3 joins it works:
Code:
function get_records()
    {
        $this->db->from('events');
        $this->db->join('locations', 'locations.location_id = events.event_location', 'LEFT');
        $this->db->join('users', 'users.user_id = events.event_creator', 'LEFT');
        $this->db->join('categories', 'categories.category_id = events.event_category', 'LEFT');

        
        $query = $this->db->get();
        
        return $query->result();
    }

I'm lost, can anyone spot the error in the first chunk of code?

And it only worked with 3 joins once I added the 'LEFT' to each of the joins. I can't find any answers.

Thanks in advance guys.


Messages In This Thread
Problem with multiple joins - by El Forum - 09-08-2009, 10:34 PM
Problem with multiple joins - by El Forum - 09-08-2009, 10:40 PM
Problem with multiple joins - by El Forum - 09-08-2009, 11:02 PM
Problem with multiple joins - by El Forum - 09-08-2009, 11:08 PM
Problem with multiple joins - by El Forum - 09-09-2009, 01:18 AM
Problem with multiple joins - by El Forum - 09-09-2009, 02:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB