$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'
)
);