Active records question, join and two id's how to get each id?? - 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 question, join and two id's how to get each id?? (/showthread.php?tid=27623) |
Active records question, join and two id's how to get each id?? - El Forum - 02-16-2010 [eluser]123wesweat[/eluser] Code: $this->db->from('tableA'); But i have an field name id in both tables, how do i get both of this id's?? At the moment i have Code: $res = $this->db_model->get_profile($user_id)->result $res->id just gives the id of tableA. How do i get tableB.id??? Active records question, join and two id's how to get each id?? - El Forum - 02-16-2010 [eluser]danmontgomery[/eluser] Code: $this->db->select('tableA.id AS a_id, tableB.id AS b_id'); Active records question, join and two id's how to get each id?? - El Forum - 02-16-2010 [eluser]123wesweat[/eluser] ah super, thanks i have added * but that's maybe not optimal right??? [quote author="noctrum" date="1266352096"] Code: $this->db->select('*, tableA.id AS a_id, tableB.id AS b_id'); Active records question, join and two id's how to get each id?? - El Forum - 02-16-2010 [eluser]danmontgomery[/eluser] By definition grabbing everything instead of only what you need is not optimal, no |