0
I am in need of help with Codeigniter. "Fell into my lap" legacy application. Below is an attempt of mine to illustrate the problem, IE, table names and fields are "scenographic".
How to make a Join ?
I need to list the list of job names and codes depending on the company and department selected in a view,
Tabela de cargo:
codigo (pk), Nome
Tabela de CargosPorEmpresa:
id (pk), IdEmpresa(fk, idDepartamento(Fk), ramal, localizacao....
$this->db->select('cargo.Nome,cargo.Codigo', false) ;
$this->db->join('cargo',[(cargo.idEmpresa = $_POST['idEmpresa']),
(cargo.idDepartamento = $_POST['idDepartamento']),'');
$this->db->where('cargosPorEmpresa.idEmpresa' , $_POST['idEmpresa']);
$this->db->where('cargosPorEmpresa.idDepartamento' , $_POST['idDepartamento']);
$this->db->order_by('cargo.Nome ASC');
$this->db->group_by('cargo.Nome,cargo.Codigo');
$query = $this->db->get('cargosPorEmpresa');