Reputation: 436
I want to display the count of rows of each table in Database. I have created a view for that in frontend
file path :..\frontend\views\site\home.php
<div class="col-md-2">
<h3>i want here $no_of_rows</h3>
<h5>Companies</h5>
</div>
And all tables is in backend folder
file path: ..\backend\controllers\CompaniesController.php
$no_of_rows = Companies::find()->count();
using that I get the no of rows... but I want to display it on the frontend. how to display the value of backend variable in frontend?
Upvotes: 2
Views: 3869
Reputation: 95
<div class="col-md-2">
<h3>
i want here <?php echo $no_of_rows ?>
</h3>
<h5>Companies</h5>
</div>
Using php echo function to print output.
Upvotes: 2
Reputation: 1314
In SiteController
:
use app\backend\models\Companies;
...
public function actionHome()
{
...
$no_of_rows = Companies::find()->count();
$this->render('home', ['no_of_rows' => $no_of_rows]);
}
Upvotes: 0