new function to sort JOIN array inside active record class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: new function to sort JOIN array inside active record class (/showthread.php?tid=51202) |
new function to sort JOIN array inside active record class - El Forum - 04-24-2012 [eluser]Unknown[/eluser] Hi, I've coded a function that sort the JOIN array (ar_join) so that the select request will join the tables without trying to access a field that doesn't exist yet. Here is an example : Code: $this->db->select('*')->from('invoice_line') This request will return an error cause you try to access to client information before you access to invoice information. The following function sort the joined tables to avoid a request error. Add this function inside the DB_active_rec.php file : Code: /** Add the execution line around line 1746, inside the "_compile_select" function ; your code should look something like that : Code: if (count($this->ar_join) > 0) Very usefull if you develop a very big application and add junctions between tables at multiple locations. You don't need to verify the join order Enjoy ! |