Hi,
I have a model named customerCredits.php
i have created a function to calculate the sum of credit the customer have
public function getCustomerCredits()
{
$criteria = new CDbCriteria();
$criteria->select = 'sum(credits) AS credits';
$criteria->compare('customer_id', (int)$this->customer_id);
return($this->findAll($criteria));
}
How can i receive the result in my controller to check if the customer have credits?
$d = CustomerCredits::model()->getCustomerCredits();
if ($d[0]->credits >= $maxCampaigns) {
$notify->addWarning(Yii::t('lists', 'You have reached the maximum number of allowed credits.'));
$this->redirect(array('campaigns/index'));
}
But always $d[0]->credits is empty