Return data from table parameters, even if result $ query is 0

1

Good night: I'm developing a project that consists of the parameters all in a parameter table ... However, in my SQL it only works if it has registers above 0: Follow the code

public function getAcompanhantes($tipo)
{
    $consulta = $this->db->query("SELECT *, p.parametro as cidade FROM cadastroperfil AS cp, parametro as p WHERE cp.verificado = '1' AND cp.codCategoria = {$tipo} AND cp.codCidade = p.idParametro")->result();

        foreach($consulta as &$valor){
            $sql =  "SELECT * FROM parametro WHERE idParametro = {$tipo}";
            $valor->Categoria = $this->db->query($sql)->row();
        }

    return $consulta;
}

Even if I change SQL to the following way, it does not work:

SELECT * FROM cadastroperfil 
LEFT JOIN parametro ON idParametro = cadastroperfil.codCategoria
WHERE cadastroperfil.codCategoria = {$tipo}

Note that in the $ query, I have requested the parameters so that I can know the city where the model is, as well as the profile data. And in the foreach next, I look for the category data, so I know if it's man, woman and so on. But, it only passes the parameters in the second, if the first has records greater than zero. I would like to see if anyone has any suggestions. Many thanks.

    
asked by anonymous 16.07.2015 / 04:22

0 answers