Gentlemen. I have the following function.
$sql = "
SELECT
c.*,
cli.*,
cli.razaosocial as nomeCliente,
c.idCliente as idClienteChamada
FROM
chamada as c,
cliente as cli
WHERE
c.idChamada = '".$id."'
AND
cli.idCliente = c.idCliente
";
$consulta = $this->db->query($sql)->result();
foreach($consulta as &$valor)
{
$sql = "
SELECT
c.*,
cli.*,
f.idFuncionario,
f.*
FROM
chamada as c, cliente as cli, funcionario as f
WHERE
c.idCliente = '".$valor->idClienteChamada."'
AND
cli.idCliente = '".$valor->idClienteChamada."'
AND
c.idFuncionario = f.idFuncionario
OR
c.idFuncionario = (NULL)
";
$valor->listaClientesView = $this->db->query($sql)->result();
}
I would like to list ALL calls even if you do not have the id in the completed call It lists all, according to the client, however, if it does not have a valid filled id, it does not list that record