Hi,
Being new to the Yii framework I’ve been trying to work out a way to filter using a relation and its parameterized scope.
Currently I’m already filtering using a few other parameterized scopes.
E.g.
$groups = GroupItem::model()->region($params['region'])->base($params['base'])->order('GrpItmCd ASC');
..
public function region($param)
{
$this->getDbCriteria()->mergeWith(array(
'condition' => 'RegionID='.$param
));
return $this;
}
public function base($param)
{
$this->getDbCriteria()->mergeWith(array(
'condition' => 'BaseID='.$param
));
return $this;
}
Now I also have another model Year which this model has a relationship too.
public function relations()
{
return array(
'yr' => array(self::BELONGS_TO, 'Yr', 'YrID')
);
}
And on this relationship model it has a named scope.
public function currentYear($param)
{
$this->getDbCriteria()->mergeWith(array(
'condition' => 'YrDsc='.$param
));
return $this;
}
Any help would be much appreciated, thanks.