• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Active records question, join and two id's how to get each id??

                $this->db->join('tableA', 'tableA.id = tableB.nameID');
                $this->db->where('user_id', $user_id);
                return $this->db->get();

But i have an field name id in both tables, how do i get both of this id's??

At the moment i have
$res = $this->db_model->get_profile($user_id)->result

$res->id just gives the id of tableA.

How do i get tableB.id???

$this->db->select('tableA.id AS a_id, tableB.id AS b_id');

ah super, thanks i have added * but that's maybe not optimal right???
[quote author="noctrum" date="1266352096"]
$this->db->select('*, tableA.id AS a_id, tableB.id AS b_id');

By definition grabbing everything instead of only what you need is not optimal, no

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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