How to findAll with specific column with order by desc ?
Code bellow worked and find all from the developer id
$id = Yii::app()->
In your model, add this function:
public function scopes() {
return array(
'bystatus' => array('order' => 'status DESC'),
);
}
Now you can do the query like this:
$models = Games::model()->bystatus()->findAll('developer_id='.$id);
=====
Bonus: You can also add this function in your model:
public function bydeveloper($devId) {
$this->getDbCriteria()->mergeWith(array(
'condition' => 'developer_id = '.$devId,
));
return $this;
}
Now you can do the query like this:
$models = Games::model()->bystatus()->bydeveloper($id)->findAll();
you can try this -
$id = Yii::app()->user->getState('id');
$model = Games::model()->findAll(array("condition" => "developer_id = '".$id."'","order" => "status"));
its should be work
You can try use criteria:
$id = Yii::app()->user->getState('id');
$criteria=new CDbCriteria;
$criteria->compare('developer_id',$id);
$criteria->order='status DESC';
$models = Games::model()->findAll($criteria);