I have a table "cars" that has the foreign fields "idbrand" and "idmodel" which references the tables "brands" and "models". Ok? Ok.
Just found a strange bug when i try the following:
$crud->set_relation('idbrand','brands','{name}')
->set_relation('idmodel','models','{name}');
If i left just one "set_relation", it works...
If i put many "set_relations", gives me the following error:
[i]Error Number: 1054[/i]
[i]Column 'jed4f12e7.name' unknown in 'field list'[/i]
[i]SELECT cars.*, CONCAT('', COALESCE(jed4f12e7.name, ''), '') as sed4f12e7, CONCAT('', COALESCE(je1f0af3d.name, ''), '') as se1f0af3d FROM (`cars`) LEFT JOIN `models` as je1f0af3d ON `je1f0af3d`.`id` = `cars`.`idmodel`[/i]
[i]Filename: .\system\database\DB_driver.php[/i]
[i]Line Number: 330[/i]
Note that it's considered only the last "LEFT JOIN" command (from "idmodel"). Where's the "LEFT JOIN" for "idbrands"?
My poor solution was to create a new protected array called "$join_cache" that flushes the left join string parameters (separated with |) when the system calls "get_list()", before the "get" command... like this:
$this->db->select($select, false);
foreach ($this->join_cache as $item)
{
$jointmp = explode("|",$item);
$this->db->join($jointmp[0],$jointmp[1],$jointmp[2]);
}
$results = $this->db->get($this->table_name)->result();
(in [i]grocery_model.php[/i])
Obviously, not a good solution and not recommended.
So... what's happening? CodeIgniter bug?
Sorry, my english is bad, very bad. :/