我需要创建一个带别名的选择,如下所示:
SELECT*, (adresses.v1 + adresses.v2) AS total FROM adresses ORDER BY distance DESC
如何在下面的代码中插入此查询?
$objects = $this->Property->find('all', array(
'recursive' => 2,
'reformat' => true,
'conditions' => $conditions,
'order' => $order,
'joins' => $joins,
));
答案 0 :(得分:1)
Try:
$objects = $this->Property->find('all', array(
'recursive' => 2,
'reformat' => true,
'conditions' => $conditions,
'order' => $order,
'joins' => $joins,
'fields' => array('*', '(adresses.v1 + adresses.v2) AS total'),
));