I have a Product (id, name, ...) model, and an OrderItem (id, order_id, product_id) model and I want to sort the products by top selling what I can get from OrderItem model.
The problem is: in yii the STAT relation is in a separate query so I cant sort it in CDbCriteria, how can I put this query in the CDbCriteria?