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 with field, don't think can order field. should give with name of relation.
  • cactiverecord doesn't have order method

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -