Reputation: 67
I'm building a website using yii framework and i have two models say Post and User.and the user model stores the preferences of the user.currently the posts are being decalre in no order as such,how do i order the posts differently for each user depending on their preferences.i want to order all posts for each user like its done on facebook.
$criteria=new CDbCriteria(array(
'order'=>'likes DSC',
));
$total = Post::model()->count();
$pages = new CPagination($total);
$pages->pageSize = 10;
$pages->applyLimit($criteria);
$posts = Post::model()->findAll($criteria);
Upvotes: 0
Views: 102
Reputation: 4607
Try DESC
, not DSC
:
$criteria=new CDbCriteria(array(
'order'=>'likes DSC',
));
Upvotes: 1