[eluser]ch5i[/eluser]
Here is a join over three tables:
device <-> device_type <-> lang_device_type
Code:
function getDevicesByUnitId($unit_id)
{
$this->db->select('*, ldt.name as typename, d.name as devicename');
$this->db->orderby('d.name', 'asc');
$this->db->join('device d', 'd.device_type_id = dt.device_type_id', 'inner');
$this->db->join('lang_device_type ldt', 'ldt.device_type_id = dt.device_type_id', 'inner');
$this->db->where('d.unit_id', $unit_id);
$this->db->where('ldt.lang_id', $this->session->userdata('lang'));
return $this->db->get('device_type dt');
}