I have 3 tables with these relation
port (countryid) ->BELONGS_TO-> country
country (regionid) ->BELONGS_TO-> region
In Port listing page, I need to show all 3 columns Cgridview including Region, which I have no problem using
array(
'header'=>$attributeLabels['regionName'],
'value'=>'$data->country->region->name',
),
But how do I ORDER BY REGION NAME in the controller?
in PortController->actionList
// no problem sorting by country using with
$dataProvider=new CActiveDataProvider('Port', array(
'criteria'=>array(
'order'=>'`t`.`countryid` ASC',
'with'=>array('country'),
),
)
)
// how to do something to this effect ?? (sort by region name)
$dataProvider=new CActiveDataProvider('Port', array(
'criteria'=>array(
'order'=>'country.region.name ASC, `t`.`countryid` ASC', //obviously not working
'with'=>array('country.region'),
),
)
)
I read about using "through" but its only for HAS_MANY and HAS_ONE…