我使用此代码。 我想检查预算< 0选择它。
$criteria = new CDbCriteria;
$criteria->select = array('*', 'SUM(amount) as budget');
$criteria->group = 'user_id';
$debtors = Transactions::model()->findAll($criteria);
我如何添加此条件?
答案 0 :(得分:2)
使用
$criteria = new CDbCriteria;
$criteria->select = array('*', 'SUM(amount) as budget');
$criteria->having = 'budget < 0 ' ;
$criteria->group = 'user_id';
$debtors = Transactions::model()->findAll($criteria);