I have a Yii query:
$criteria->select = 't.baniid,SUM(t.impression) AS impression, SUM(t.`unique`) AS `unique`, IFNULL((SELECT SUM(clicks) FROM _clicksdaily WHERE baniid=t.baniid GROUP BY baniid), "0") AS clicks';
$criteria->group = 't.baniid';
The query runs fine and get all the parameters back. the problem is that the impressions model doesnt have click attribute and it doesnt show as an attribute (so i can’t use it in a widget)…
Any idea how can i assign another attribute from SQL query? (I added public $clicks, but it doesnt work).
Thanks.
The
public $clicksseems to work for me.In your model:
Then use it: