Reputation: 23
What method mysql use in Yii 1.1 when adding? Here is the code I use but the sum method does not work:
$query = Yii::app()->db->createCommand()->from('users_payouts');
sum = $query->sum('sum');
In the browser, it gives an error:
In the CDbCommand class and its behaviors, no method or closure named "sum" was found.
Upvotes: 0
Views: 187
Reputation: 22174
There is no shortcut for sum, you should define correct select
:
$sum = Yii::app()->db->createCommand()
->select('SUM(some_column)')
->from('users_payouts')
->queryScalar();
Upvotes: 3