Answer the question
In order to leave comments, you need to log in
How to do grouping with sorting in Yii query?
There is such a request, you need to sort the Catalog by the sort field and group
$models = Catalog::model()->with(array(
'model' => array(
'order'=>'t.sort ASC',
),
'model.parent_model'=>array(
'select'=>false,
'condition'=>'model.parent=:parentId',
'params'=>array(':parentId'=>$selectedModel->parent_model->id),
),
))->findAll(
array(
'condition'=>'gallery_photo_id=:galleryPhoto',
'params'=>array(':galleryPhoto'=>$galleryPhoto->id),
'order' => 't.sort ASC',
'group' => 't.model_id'
)
);
Answer the question
In order to leave comments, you need to log in
The selection also includes sorting and grouping. What exactly is the problem?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question