Nicolas400
(Nicolas Machado)
February 12, 2015, 1:29pm
1
Hi, I have two tables related with HAS_MANY
public function relations() {
return array(
'cuotas' => array(self::HAS_MANY, 'Cuota', 'liquidacion_id'),
);
}
When I use $model->cuotas , I get all "cuota" object as usual.
My question is that I need to SORT, that info.
Is there any way to do that ?
Best Regards
Bizley
(Bizley)
February 12, 2015, 1:52pm
2
'cuotas' => array(self::HAS_MANY, 'Cuota', 'liquidacion_id', 'order' => 'cuotas.columnNameToSort'),
http://www.yiiframework.com/doc/api/1.1/CActiveRecord#relations-detail
georaldc
(Georaldc)
February 12, 2015, 9:43pm
3
Another option is to pass an array that contains criteria related keys to your relation. This gets merged to the query that gets generated from your relation. Example:
$sortedObjects = $model->cuotas(array(
'order' => 'cuotas.columnNameToSort',
));