MySQL Join and active record issue (tables have same named fields) - 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: MySQL Join and active record issue (tables have same named fields) (/showthread.php?tid=8860) |
MySQL Join and active record issue (tables have same named fields) - El Forum - 06-03-2008 [eluser]skattabrain[/eluser] I'm stumped here. I run this query ... Code: $this->db->from('users'); which ends up looking like this ... SELECT * FROM (`users`) JOIN `clients` ON clients.clientID = users.clientID WHERE `id` = '3' LIMIT 1 Problem - both the users and the clients table have columns called 'aol' and 'msn' ... but if i do a var_dump on my query result, it looks like it's dropping 1 of the aol's. if i do the same query in a console ... i get both values. So how do I access these variables? I used to do it by doing a select from 'table1', 'table2' ... will i have to explicitly build my select clause? ie ... select clients.aol, users.aol etc ... MySQL Join and active record issue (tables have same named fields) - El Forum - 06-03-2008 [eluser]charlieD[/eluser] I had this issue yesterday - what I had to do was use the AS keyword: $this->db->select('users.aol AS usersAOL, 'clients.aol AS clientsAOL'); $this->db->from('users'); etc... MySQL Join and active record issue (tables have same named fields) - El Forum - 06-03-2008 [eluser]skattabrain[/eluser] thanks charlie ... i was hoping to still use select * but this will probably not be possible with active record. MySQL Join and active record issue (tables have same named fields) - El Forum - 06-03-2008 [eluser]Référencement Google[/eluser] [quote author="skattabrain" date="1212534791"]thanks charlie ... i was hoping to still use select * but this will probably not be possible with active record.[/quote] And so would it be also without Active Record... |