I am new in Yii framework. I have a page frontend/site/home.php, I want to display the number of records from companies table at home.php.(DB name yii2advanced)
Asked
Active
Viewed 2,880 times
-3
1 Answers
3
Simply use count
function to get count of records from a table, like -
$count = YourModel::find()->count();
echo $count;

Rohit Suthar
- 3,528
- 1
- 42
- 48

Ajil MV
- 58
- 1
- 7
-
-
2I think it is due to you are not passing '$count' from action to view session. return $this->render('home',['count' => $count]); – Ajil MV Dec 08 '17 at 10:37
= "$result"; ?>
Companies