I have the following problem
3023
Table1 has a MANY_MANY relation between Table2. And Table2 has a HAS_MANY relation between Table3. Everything is good inside model classes.
Inside my view, I could do:
$table1 = Table1::model()->with('table2')->findByPk($pk);
And get all the table2 data that is associated with that Table1 row using
$table1->table2;
But, if I wanted to get all Table3 data, I would do:
$table1 = Table1::model()->with('table2')->findByPk($pk);
$table2 = $table1->table2;
$table2Ids = array();
foreach ($table2 as $t) {
array_push($table2Ids , $t['id']);
}
$table2 = Table2::model()->with('table3')->findByPk($table2Ids);
$table3 = $table2->table3;
Is there another way to do this? Something like :
Table1::model()->with('table2')->with('table3')->findByPk($pk)->table2->table3;