I have the following code
$sql = "
SELECT
c.*,
cl.razaosocial,
cl.idCliente
FROM
chamada as c,
cliente as cl
WHERE
c.idCliente = cl.idCliente";
$consulta = $this->db->query($sql)->result();
foreach($consulta as &$valor)
{
$this->db->where('idFuncionario', $valor->idFuncionario);
if($this->db->get('funcionario')->row('nome'))
{
$valor->funcionarioNome = $this->db->get('funcionario')->row('nome');
}
else
{
$valor->funcionarioNome = "";
}
}
return $consulta;
It returns in $valor->funcionarioNome
always the same name.
What would have gone wrong there?
I thought of trying to do this SQL, it only displays those that are set the employees on the call, but there are calls in "open" with no elected officials yet.
SELECT c.*, f.nome as nomeFuncionario, f.idFuncionario, cl.razaosocial, cl.idCliente FROM chamada as c, cliente as cl, funcionario as f WHERE c.idCliente = cl.idCliente AND c.idFuncionario = f.idFuncionario GROUP BY c.idFuncionario