php - How to pagination from multiple query yii2? -


i want pagination results in yii2.but more 1 table. here action code of site controller:

<?  public function actionpagination_product(){  $query=product::find();    $count=$query->count();    $pagination=new pagination(['totalcount' => $count, 'defaultpagesize' => 1]);     $models = $query->offset($pagination->offset)        ->limit($pagination->limit)        ->all();  	    	     return $this->render('pagination_pro', [        'models' => $models,        'pagination' => $pagination,     ]);    }      ?>

and here view:

<?php     use yii\widgets\linkpager;  ?>  <?php foreach ($models $model): ?>     <div class="list-group">    <a href="#" class="list-group-item active">      <h4 class="list-group-item-heading"><?= $model->title; ?></h4>      <p class="list-group-item-text"><?= $model->id; ?></p>  	 <p class="list-group-item-text"><?= $model->body; ?></p>    </a>  </div>           <br/>  <?php endforeach; ?>  <?php     // display pagination     echo linkpager::widget([        'pagination' => $pagination,     ]);  ?>

this searching in multiple tables , can not join them.

for example want read report::find() in pagination

how that?

i not sure if understanding questions correctly. if problem "and can not join them.". can join tables want show using in controller:

$model = report::find() ->join('inner join', 'othermodel', 'othermodel.report_id = report.id'); ->all(); 

this way have data need in variable $model , can want it.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -