I wanted to ask is it possible to specify a where clause after a join in order to match data to a users input. Say for example I have the following code:
$this->db->select('user.*,role.*')
$this->db->from('user');
$this->db->where('user.username', $username);
$this->db->where('user.password', $password);
$this->db->join('role','role.id = user.role_id')
$result = $this->db->get();
and I want to query the matching data from the table ‘role’:
$this->db->select('user.*,role.*')
$this->db->from('user');
$this->db->where('user.username', $username);
$this->db->where('user.password', $password);
$this->db->join('role','role.id = user.role_id')
$this->db->where('role.speaker', $speaker); //want to know if this is correct
$result = $this->db->get();
Is this possible? Can I compare results (using WHERE) after a JOIN? Will that produce results matching to the WHERE clause?
Thanks!
CodeIgniter doesn’t actually build the query until
->get()is called. You can call the methods in whatever order you want.