I have news table and its related news_comment table. I have defined relation newsComment with news_comment table.
If I execute this query:
$result = News::getDb()->cache(function () use($id) {
return News::find()->with('newsComment')->where(['news.id' => $id])->one();
});
Only query that is fetching data from news table will be cached. Query that is selecting from related table is not.
Is it possible to cache both main query and queries executed to retrieve data from related tables together, without having to write them separately ?
joinWith
? yiiframework.com/doc-2.0/… – Complete