[eluser]comyou[/eluser]
[quote author="CroNiX" date="1390069688"]You would use a join. I'll show the concept and you can go from there...You can fine tune with db::where(), and an additional join on your agent table, grab additional fields, etc
Users
-id
-role_id
-email
-name
Roles
-id
-name
Code:
//get all user names and email from user table, and their role_name from roles table
//since users and roles table both have a "name" column, alias the role.name as role_name to avoid collision
$users = $this->db
->select('users.email, users.name, roles.name as role_name')
->join('roles', 'roles.id = users.role_id', 'left') //get the role where the role.id = the users.role_id
->get('users')
->result();
[/quote]
Thanks, never thought of using join.
Sorted it right out, had to use $this->db>query though because it wasn't working using the ->select->join->get, but that's no issue.
+1 internet points for you sir.