A table Product
contains has_many relationship with a table **Slab**
that further contains has_many relationship with a table Rate
.
A relational query is wrapped inside CActiveDataProvider
that joins three tables across certain parameters and return products in descending order of their respective rates.
I want to show the results in tabular form through CGridView
.
Trying to access only certain columns through following syntax:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'name','slabs.id','slabs.rates.rate'
)
));
Unfortunately I can't access slabs.id
because when I dump dataProvider
object I see that it is annexed to Product
object through an Array whose index[0]
contains the Slab
object, then under Slab
object index[0]
has the rates.rate
object.
It is probably occurring because of the has_many relationship between tables but my query would always return one Slab
and one Rate
object.
How may I access and show them?