[eluser]Jakobud[/eluser]
I have two basic database tables like so:
Code:
table: clients
columns: id, name
table: projects
columns: id, name, client_id
This is the MySQL query I want to run:
Code:
SELECT projects.id, projects.name, clients.name
FROM projects, clients
WHERE projects.client_id = clients.id
I'm trying to figure out how to do this with ActiveRecord. I tried this:
Code:
$this->db->select('projects.id, projects.name, clients.name');
$this->db->from('projects, clients');
$this->db->where('projects.client_id = clients.id');
$this->db->get();
This seems to work, however it only returns projects.id and clients.name. It's like it ignores projects.name since it shares the same column name as clients.name. Also it turns those column names as 'id' and 'name' instead of 'projects.id' and 'clients.name'.
Is there an easier way to write this that I'm just not seeing in the User Guide or Wiki?