• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Potential Bug In ActiveRecord when doing compound join statement

#1
[eluser]blasto333[/eluser]
View Database Schema


Code:
$this->db->from('sales');
$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();

produces:
Code:
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?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.