I have a Yii Powered web app with a controller (PostController) and a “view” column in database.
How can I update these rows when visitors view Post page?
Now my code is working, but is it correct or are there any comments/suggestions?
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
Quotes::model()->updateCounters(array('views'=>+1), 'id=' . $id );
}
in the Quotes model:
this will update views everytime after find.
in controller: