如何在使用cakephp的条件下使用sum函数

时间:2016-12-10 18:37:27

标签: mysql cakephp

您好我正在尝试进行查询,我需要在where条件中传递sum函数。以下是查询。

$this->Transaction->virtualFields['total_amount'] = 'sum(total_amount)';
$this->paginate = array('conditions'=>$conditions,'order' => 'Transaction.title ASC', 'limit' => '15','group'=>'Transaction.order_id');

1 个答案:

答案 0 :(得分:0)

尝试使用型号名称

$this->Transaction->virtualFields['total_amount'] = 'sum(total_amount)';

将其更改为

$this->Transaction->virtualFields['total_amount'] = 'sum(Transaction.total_amount)';