search query in cakephp

1

I want to do a query that finds the date, but the query below is finding even when I do not pass value or when it is a value that has nothing to do with date:

$busca = $this->Despesa->find('all', array('data_despesa' => '2'));

In this query there was nothing to return. But you're bringing everything in, like a select * from nomeDaTabela .

What's wrong?

I'm trying to make sql out of the standard framework, how would it be? I have already seen something like this: $this->query("codigo dml");

    
asked by anonymous 22.10.2015 / 01:04

1 answer

3

What happens is that you made a mistake in the values of the second parameter. The method find() expects as second parameter an array with a or more of the following keys: conditions, limit, recursive, page, fields, offset, order, callbacks.

To use conditions like you want, you should use the conditions key, which is an array , like this:

$busca = $this->Despesa->find('all', array('conditions' => array('data_despesa' => '2015-10-21')));

For the second question, using the method query()

22.10.2015 / 01:25