Active Records SQL join 4 tables help revise code - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Active Records SQL join 4 tables help revise code (/showthread.php?tid=40684) |
Active Records SQL join 4 tables help revise code - El Forum - 04-15-2011 [eluser]kreynol7[/eluser] Hi, Im creating a dating application, and need to join 4 tables and display members that have a date coming up the soonest. Here is my regular sql code that works BUT WHEN CONVERTED CODE BELOW TO ACTIVE RECORDS...KEEP READING Code: select me.member_id HERE IS MY ACTIVE RECORD ATTEMPTS IN CI Code: $this->db->select('me.member_id THE CODE DOES NOT RETURN AN ARRAY OF DATA, IN FACT THERE ARE NO ERRORS RETURNED EITHER, NO DATA AND NO ERRORS? CAN ANYONE FIX THIS CODE, ANY SYNTAX ERRORS? THANKS Active Records SQL join 4 tables help revise code - El Forum - 04-15-2011 [eluser]bubbafoley[/eluser] just to be sure. are you calling db->get() at the end? Code: $this->db->select('me.member_id Active Records SQL join 4 tables help revise code - El Forum - 04-15-2011 [eluser]kreynol7[/eluser] hey thanks for such a fast reply, the output is just - array () so it returns an empty array Active Records SQL join 4 tables help revise code - El Forum - 04-15-2011 [eluser]bubbafoley[/eluser] hmm I seem to remember having trouble with active record stuff and aliasing table names. try changing the wheres to this: Code: $this->db->where('me.member_id = mwn.member_id'); you can also use joins Code: $this->db->select('me.member_id Active Records SQL join 4 tables help revise code - El Forum - 04-16-2011 [eluser]toopay[/eluser] Code: $query = $this->db->select('me.* , mwn.* , mwr.*') |