How to make BETWEEN in CAKEPHP?

1

I'm doing a query in the database and I need to get information between two values of the valor column that are within the specified amount.

For example: Between valorMinimo 300 and valorMaximo 600

$imovel = $this->Imovel->find('all', array(
    'conditions' => array(
        'valor' => $queries['valorMin'], 'valor' => $queries['valorMax']
    )
));
    
asked by anonymous 10.03.2014 / 18:39

1 answer

3

According to your own CakePHP documentation , your condition would look like this :

$imovel = $this->Imovel->find(
    'all',
    array(
        'conditions' => array('valor BETWEEN ? AND ?' => array(
            $queries['valorMin'],
            $queries['valorMax'])
        )
    )
);

PS: Please test, it is not my main framework:)

    
10.03.2014 / 18:57