As a suggestion try the following modification.
As I do not know your accurate tables name, I call them first
, second
and third
relatively.
In your first
model, put the following relation:
'second' => array(self::HAS_MANY, 'SECOND_TABLE_MODEL', 'FIRST_TABLE_KEY_WHICH_IS_RELATED_TO_SECOND')
In your second
model, put the following relation:
'third' => array(self::HAS_MANY, 'THIRD_TABLE_MODEL', 'SECOND_TABLE_KEY_WHICH_IS_RELATED_TO_THIRD')
now, let's skip the third
table relations. I consider you only want to access the description
in third
table.
Then, if you do like bellow:
$firstRecords=First::model()->findAll();
You have all records from your First
table. You do not need to use with
here. to access the second
table data, which is related to first
table you can do like below:
foreach($firstRecords as $fr){
//$fr->second->ATTRIBUTE_NAME
}
Finally, if you want to access the description
from third
table you can do like bellow:
foreach($firstRecords as $fr){
$second=$first->second;
foreach($second->third as $st){
//$st->description
}
}
I hope it help