SELECT
MemberId,
OrganizationId,
SUM(Amount) AS `Amount Donated to Organization`,
COUNT(Amount) AS `Number of Donations`
FROM
Donations
GROUP BY
MemberId,
OrganizationId
;
will give me what I need …
In my donation model I want to use this info in CGridView. This is where I need the help.
I tried creating a function but all it does is give me a count on the different organizations.
public function getBalanceAmount () {
$dbCommand = Yii::app()->db->createCommand(
"SELECT
MemberId,
OrganizationId,
SUM(Amount)
FROM
Donations
GROUP BY
MemberId,
OrganizationId;"
)->execute();
return $dbCommand;
}
So how can I directly use this sql and then call it into my gridview?