Welcome Guest, Not a member yet? Register   Sign In
How to get table.column in active record queries?
#4

[eluser]kaejiavo[/eluser]
Quote:The only alternative I’ve found so far is to specify what I’m selecting first:

$this->db->select('user.id AS user_id, role.id AS role_id');
But I thought perhaps there was a different way to do it with active record… Any thoughts?


Jakobud,

what you descripe happens to all columns with the same name in your joined tables. The most right column will be the only in the result.
I ran into the same problem, and found no way to use aliases with AR but manually write the select statement as you have done as alternative.
Maybe an AR expert can give us some help here, or takes this issue (using column aliases for joined tables) to the AR feature request list.

Marco

@ToddyBoy
there is definitely no difference for this issue using the object or array result set.

@Veishu
this is a standard SQL requirement. Only because you want to join 2 tables, there is no obvious need for an ORM i would say. For using DMZ your tables and relations have to follow special conventions, which is o.k. but doesn't suit everyone.


Messages In This Thread
How to get table.column in active record queries? - by El Forum - 08-24-2010, 06:23 PM
How to get table.column in active record queries? - by El Forum - 08-24-2010, 06:39 PM
How to get table.column in active record queries? - by El Forum - 08-24-2010, 09:47 PM
How to get table.column in active record queries? - by El Forum - 08-25-2010, 12:49 AM
How to get table.column in active record queries? - by El Forum - 08-25-2010, 01:17 AM
How to get table.column in active record queries? - by El Forum - 08-25-2010, 08:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB