Yii : how to count records in a model?
php, yii
Solution
$notifyModels = Notification::model()->findAllByAttributes(array(
'user_id'=> Yii::app()->user->uid
));
$count = count($notifyModels);
Or
$count = Notification::model()->countByAttributes(array(
'user_id'=> Yii::app()->user->uid
));
Problem
I have following code to fetch data from a model. ``` $notifyModel = Notification::model()->findByAttributes(array( 'user_id'=> Yii::app()->user->uid )); ``` Now I want to count the number of rows fetched. Neither `$notifyModel->count()` work nor `count($notifyModel)`. It is very simple but googling did not help.