Please consider this:
class User extends CActiveRecord
{
...
public function relations()
{
return array(
...
'articleCount' => array(self::STAT, 'Article', 'userid'),
...
);
}
...
}
Now, I need to create a $dataProvider = new CActiveDataProvider(...)
to feed a CListView
widget to which I want add articleCount
to the property sortableAttributes
so that I can sort User records according to the number of articles the user is the author for.
What are the most convenient method? what are the other alternatives?