Welcome Guest, Not a member yet? Register   Sign In
MySQL Join and active record issue (tables have same named fields)
#1

[eluser]skattabrain[/eluser]
I'm stumped here. I run this query ...

Code:
$this->db->from('users');
$this->db->where('id', $userID);
$this->db->join('clients', 'clients.clientID = users.clientID');
$this->db->limit(1);
$query = $this->db->get();

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 ...


Messages In This Thread
MySQL Join and active record issue (tables have same named fields) - by El Forum - 06-03-2008, 10:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB