Welcome Guest, Not a member yet? Register   Sign In
flexi auth - A user authentication library for CodeIgniter

[eluser]haseydesign[/eluser]
@devha

Your assumption is correct, when CodeIgniters Active Record returns the SQL query as an object/array, any identically named columns will be overwritten by the value within the last column of the same name.
This is CI's default behaviour, and to be honest, exactly what I would expect it to do - it can't rename the columns as it doesn't know what to name them.

One potential solution would be to use flexi auth functions that allow you to define the SQL SELECT columns.
You could then define identically named columns as follows:
Code:
$user_id = 123;
$sql_select = 'user_accounts.id AS "user_accounts_id", user_groups.id as "user_groups_id", ...''
$this->flexi_auth->get_user_by_id($user_id, $sql_select);

But as you can probably gather from that code - why bother...
Just name the columns uniquely in the first place and this problem doesn't exist.
It's a practice I always try to implement as it just prevents such small but crippling problems from arising, plus it removes ambiguity, as when you look at the column name - you should easily be able to work out what table its from.


Messages In This Thread
flexi auth - A user authentication library for CodeIgniter - by El Forum - 06-03-2013, 04:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB