Welcome Guest, Not a member yet? Register   Sign In
Potential Bug In ActiveRecord when doing compound join statement

View Database Schema

$this->db->join('sales_items', 'sales.sale_id = sales_items.sale_id');        
$this->db->join('sales_items_taxes', 'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id');
$res =  $this->db->get();

echo $this->db->last_query();

SELECT * FROM (`phppos_sales`)
JOIN `phppos_sales_items` ON `phppos_sales`.`sale_id` = `phppos_sales_items`.`sale_id`
JOIN `phppos_sales_items_taxes` ON `phppos_sales_items`.`sale_id` = `phppos_sales_items_taxes`.`sale_id`
AND sales_items.item_id = sales_items_taxes.item_id

Notice how the second condition in the 2nd join doesn't have prefixes on the tables. Therefore the query fails. How can I achieve what I am trying to do?

Theme © iAndrew 2016 - Forum software by © MyBB