CDetailView with three table

How to display the information in third table?

table one:

tbl_student

id

teacher_id (Foreign Key, Points to id in tbl_teacher, with relation "studentTeacher")

table two:

tbl_teacher

id

clothe_id (Foreign Key, Points to id in tbl_clothe)

table three:

tbl_clothe

id

brand

All the following code are in student table context.

<?php

        &#036;this-&gt;widget('zii.widgets.CDetailView', array(


            'data' =&gt; &#036;model,


            'attributes' =&gt; array(





               &quot;studentTeacher.clothe_id&quot;,  --- It's OK


                


                array(


                'label' =&gt; 'Clothe Brand',


                'type' =&gt; 'raw',


                'value'=&gt;,                    --- need some code here


                ),





               


            ),


        )); ?&gt;

How to get the "brand" in tbl_clothe in Student context?

Thanks.

You should set the relations in both student and teacher (if you have foreign key in database, gii generates all for you).

Then you can simply write here:

$model->teacher0->clothe0->brand

That works if in student you have the relation teacher0 on tbl_teacher and if in teacher you have the relation clothe0 on tbl_clothe, oterhways you have to adapt the code accordingly to relations.