php - Sorting related models in a Yii findByPk() -
using yii framework, how can sort related model modifiervalues "sortorder asc, name asc"? have tried order->('modifiervalues.sortorder asc, modifiervalues.name asc') no avail
<?php $item = item::model() ->with("modifiergroups.modifiervalues") ->findbypk($id); ?>
try
$item = item::model() ->with('modifiergroups') ->find(array( 'condition'=>'id = :id', 'params'=>array('id'=>$id), 'order'=>'modifiervalues.sortorder asc, modifiervalues.name asc' ) ); or (i haven't tried one, should work same)
$item = item::model() ->with(array('modifiergroups'=>array('order'=>'modifiervalues.sortorder asc, modifiervalues.name asc'))) ->findbypk($id)); notes:
- if give
withfield, don't think can order field. should givewithname of relation. - cactiverecord doesn't have
ordermethod
Comments
Post a Comment