- table Books
- table Authors
- table Authors_Category
In Books
model have relation:
public function relations()
{
return array(
'authors' => array(self::BELONGS_TO, 'Authors', array('author_id'=>'id')),
}
In Authors
:
public function relations()
{
return array(
'authors_category' => array(self::BELONGS_TO, 'Authors_Category', array('author_cat'=>'id')),
}
In Books
DataGridView
I can access Authors_Category
fields
$data->authors->authors_category->category_name
But problem is in sorting Authors_Category
colums
In Books
model I have sorting rule:
return new CActiveDataProvider(
new FraudAlerts(),
array(
'criteria'=>$criteria,
'sort'=>array(
'attributes'=>array(
'category_name'=>array(
'asc'=>'Authors_Category.category_name',
'desc'=>'Authors_Category.category_name DESC',
),
)
)
)
);
When I try sort by Authors_Category
fiels I get error, that col category_name not exist.
What is wrong in my relations in Books
model ?