[code]
$links = Link::model()->with('votes')->findAll(array(
'select' => 'SUM(karma_delta) AS karma',
'condition' => 'links.id = votes.link_id',
'group' => 'votes.link_id',
'order' => '(SUM(votes.karma_delta) - 1) / POW((TIMESTAMPDIFF(HOUR, links.created, NOW()) + 2), 1.5) DESC',
));
[code]
How do I access karma in my views? They don't seem to show up when I print_r my $links variable.
Page 1 of 1
When SUMing a Column in AR, how do you access it's value?
#2
Posted 22 November 2009 - 05:00 AM
Took me a while but I figured it out! Just had to add
to my model and all was good.
public $karma;
to my model and all was good.
#3
Posted 23 November 2009 - 03:57 AM
You could also define a statistical relation, see http://www.yiiframew...de/database.arr
Share this topic:
Page 1 of 1

Help













