Welcome Guest, Not a member yet? Register   Sign In
Active Record Class
#1

[eluser]vickel[/eluser]
Hi all, while I was writing queries using INNER JOIN I run into something ...

my table 'booking_rates' has a column called 'ID' as do the 2 joined tables

Code:
$this->db->where('object_ID', $id);
        $this->db->join('booking_periods', 'booking_periods.ID = booking_rates.periodID', 'inner');
        $this->db->join('booking_seasons', 'booking_seasons.ID = booking_rates.seasonID', 'inner');

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


my result function returns the value of booking_seasons.ID instead of booking_rates.ID

btw: below works fine !

Code:
$query = $this->db->query('
        SELECT booking_rates.*, booking_periods.description, booking_seasons.seasondefinition, booking_rates.ID
        FROM (booking_rates
        INNER JOIN booking_periods ON booking_rates.periodID = booking_periods.ID)
        INNER JOIN booking_seasons ON booking_rates.seasonID = booking_seasons.ID
        WHERE (((booking_rates.object_ID)='.$id.'));');

        return $query->result();

any ideas where I'm wrong in the active record query?

thanks
#2

[eluser]xeroblast[/eluser]
try to add $this->db->select() manually...
#3

[eluser]InsiteFX[/eluser]
You can try this, but I have not tested it...

Code:
$this->db->select('booking_rates.*, booking_periods.description, booking_seasons.seasondefinition, booking_rates.ID');

$this->db->from('booking_rates');

$this->db->where('object_ID', $id);

$this->db->join('booking_periods', 'booking_periods.ID = booking_rates.periodID', 'inner');
$this->db->join('booking_seasons', 'booking_seasons.ID = booking_rates.seasonID', 'inner');
        
$query = $this->db->get();

return $query->result();

InsiteFX
#4

[eluser]vickel[/eluser]
thanks InsiteFX, your select() clause didn't work, i think I stick to the solution with $query = $this->db->query()




Theme © iAndrew 2016 - Forum software by © MyBB