Welcome Guest, Not a member yet? Register   Sign In
Multiple Tables in FROM Statement in DB Active Record
#2

[eluser]Seppo[/eluser]
You can do it with active record... however it's better if you use Joins instead...
As you posted it
Code:
$this->db->select('person.person_id, person.name, bew2proj.status_id, bew2proj.b2w_id, company.company_id, company.name');
        $this->db->from(array('bew2proj', 'person', 'company'));
        $this->db->where('bew2proj.person_id = person.person_id');
        $this->db->where('person.company_id = company_id.company_id_id');
        $this->db->where('person.company_id', $company_id);
        $this->db->where('bew2proj.projekt_id', $this->input->post('ID'));

Using joins
Code:
$this->db->select('person.person_id, person.name, bew2proj.status_id, bew2proj.b2w_id, company.company_id, company.name');
        $this->db->from('bew2proj');
        $this->db->join('person', 'bew2proj.person_id = person.person_id');
        $this->db->join('company', 'person.company_id = company_id.company_id_id');
        $this->db->where('person.company_id', $company_id);
        $this->db->where('bew2proj.projekt_id', $this->input->post('ID'));


Messages In This Thread
Multiple Tables in FROM Statement in DB Active Record - by El Forum - 04-13-2008, 10:46 AM
Multiple Tables in FROM Statement in DB Active Record - by El Forum - 04-13-2008, 10:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB