bigbasher
(Adriaan)
December 29, 2011, 2:16pm
1
I am trying to load a resultset in a nice single tidy line:
$fees=Fees::model()->search()->getData();
this works just fine. Now I want this to be ordered - is something like the following possible?
$fees=Fees::model()->search()->setSort(array('defaultOrder'=>'min_amount'))->getData();
Well, you can either overwrite your model’s defaultScope(), add another scope and call it via with() or set CDbCriteria.order within your model’S search() method.
tri
(tri - Tommy Riboe)
December 29, 2011, 4:26pm
3
This may work (store MyActiveDataProvider.php in protected/components, change model search() to instantiate MyActiveDataProvider)
<?php>
class MyActiveDataProvider extends CActiveDataProvider
{
public function setSort($value)
{
parent::setSort($value);
return $this;
}
}
(untested)
/Tommy