I am making an inquiry and the cake is bringing all data ignoring $ conditions. I want to search by date, but when I put a date that does not exist in any record, it still brings all the data.
public function consultarDespesa() {
if ($this->request->is('post')) {
$dataDespesa=null;
$dataDespesa = $this->request->data['Despesa']['ano']."-".$this->request->data['Despesa']['mes'];
$despesas = $this->Despesa->find('all', array(
'conditions'=>array(
'data_despesa like'=>"%$this->dataDespesa%")));
if (($despesas==null) || (!isset($despesas))) {
$this->Session->setFlash("Sua pesquisa não retornou nenhum resultado.");
}
else {
$this->Session->write("Despesas", $despesas);
$this->redirect(array('action'=>'exibirDespesas'));
}
}
}