Passing sql in array index CAKEPHP

1

I need to do 3 queries, if x icon is enabled, make X query. If it is the y icon, query y. If the 2 are, I want everything from the query x and y.

I can get the query x and y, but at the time of getting all of the 2 queries I can not.

Ifs to check the items.

 if(in_array('pacote',$criterios_pesquisa) && in_array('curso',$criterios_pesquisa)){
        $criterios['Curso.pacote '] = ? ;
    }
        if(in_array('pacote',$criterios_pesquisa)){
            $criterios['Curso.pacote'] = 1;
        }
        if(in_array('curso',$criterios_pesquisa)){
            $criterios['Curso.pacote !='] = 1;
        }

In my database packages can be 1 or 0, as you see it was done, or get pacote = 1 or pacote != 1 , I'm having trouble getting the 2.

@edit

I did it that way and I managed to solve it, if anyone has any more 'beautiful' method, feel free.

if(in_array('pacote',$criterios_pesquisa)){
            $criterios['Curso.pacote'] = 1;
        }
        if(in_array('curso',$criterios_pesquisa)){
            $criterios['Curso.pacote !='] = 1;
        }
        if(in_array('pacote',$criterios_pesquisa) && in_array('curso',$criterios_pesquisa)){
            unset($criterios['Curso.pacote']);
            unset($criterios['Curso.pacote !=']);
        }
    
asked by anonymous 01.06.2015 / 17:21

0 answers