Doubt with conditions in cakephp?

1

I'm trying to make a conditions into a find . I have 2 tables: tipopessoas and pessoas , in table pessoas I have a foreign key for table tipopessoas . I want my find to bring the result just for two types of people, RESPONSAVEL and PROFESSOR , so I'm trying to use a find with conditions using OR , but only one result returns.

How do I get the 2 types of people back and not just 1?

I'm trying like this.

$this->set("pessoas", $this->User->Pessoa->find('list', array(
                                                        'fields' => array("Pessoa.id", "Pessoa.nome", "Pessoa.tipopessoas_id",'Tipopessoa.id','Tipopessoa.descricao'),
                                                        "conditions"=>array("OR"=>array('Tipopessoa.descricao = '=>'RESPONSAVEL', 
                                                                                        'Tipopessoa.descricao = '=>'PROFESSOR')),
                                                        'recursive' => 0))); 
    
asked by anonymous 01.09.2015 / 14:54

1 answer

2

Well, you're almost there. What you have to do is something of the genre:

"conditions"=>array("OR"=>array(
    array('Tipopessoa.descricao' =>'RESPONSAVEL'),
    array('Tipopessoa.descricao' =>'PROFESSOR') )
 )

Another method you can use is:

"conditions"=> array('Tipopessoa.descricao' => array('RESPONSAVEL', 'PROFESSOR'));
    
01.09.2015 / 16:08