Answer the question
In order to leave comments, you need to log in
What is the correct way to work with eager loading when using ListView widget?
I'm trying to organize work LIstView
with links and eager loading like this I organize eager loading
$allGods=Gods::find()->with('prise','images','addfeilds')->all();
<?= ListView::widget([
'dataProvider' => $productsDataProvider,
'itemView' => '_gods',
'viewParams' => [
'allGods' => $allGods,]
]) ?>
var_dump($model->images)
sql
request. I understand that I am doing something wrong. Do not tell me how to do it right?
Answer the question
In order to leave comments, you need to log in
when using eager loading, you will always have one additional request to load the relation (it doesn’t matter if you use with or joinWith), because the framework needs to somehow load the relation objects. Another question is how critical such requests are for your system and how much your architecture allows you to get rid of them. If your project uses one database and the presence of additional queries is too critical, use a regular join
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question