I'm trying to select records in a date range.
$mesAtual = $this->requestAction(array('controller' => 'compras', 'action' => 'comprasMes'), array('condicoes' => array('Compra.status' => array(1,2), 'Compra.data BETWEEN ? AND ?' => array('06/30/2015', '07/30/2015')), 'ordem' => array('Compra.data_pagamento' => 'desc')));
What happens is that the records have returned but I can not sort the data: 'ordem' => array('Compra.data_pagamento' => 'desc')
.
See how it is in the controller
public function comprasMes(){
$condicoes = $this->params->params['condicoes'];
$ordem = isset($this->params->params['ordem']) ?: null;
$compras = $this->Compra->find('all', array( 'conditions' => array($condicoes), $ordem ));
return $compras;
}