kbradwick
(Kbradwick)
1
I have a result object set out like this…
$criteria = new CDbCriteria;
$criteria->select = 'SUM(credit_amount) AS balance';
$criteria->condition = 'user_id = :id';
$criteria->params = array(':id'=>$user->id);
$result = Transaction::model()->find($criteria);
I’ve aliased the SUM as balance but cannot access the balance property the obvious way i.e.
$result->balance;
An exception is thrown stating the table column doesn’t exist. How do I access the ‘balance’ property of the result set?
tri
(tri - Tommy Riboe)
2
Just declare it as a public member of the model class.
/Tommy
kbradwick
(Kbradwick)
3
That worked. Thanks Tommy