CodeIgniter Forums

Full Version: Proper use of join
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I got a problem - when i use code like this one
$this->db->select(', u.username,', false);
$this->db->from('user as u');
$this->db->join('companies as c', 'u.company_id =');
$this->db->where('LOWER(u.username)=', strtolower('foobar'));
$query = $this->db->get();

i loose all my id.
I tried to change names of id fields to something like user_id, but CI don't work well without column named precisely id.

How to don't loose id field?
And is possible to get an object representation after a querry that uses a join statement?
Or it would be better just use a second query?
I think you're looking for

PHP Code:
select(' AS user_id, ...'

Although, I'm only seeing where you would get anyway, you've not called for any other ids in the select statement. 

To get the result object:

PHP Code:
$obj $this->db->result() // or row()