Frontend\Modules\Faq\Engine\Model::increaseViewCount PHP Method

increaseViewCount() public static method

Increase the number of views for this item
public static increaseViewCount ( integer $id ) : array
$id integer
return array
    public static function increaseViewCount($id)
    {
        FrontendModel::getContainer()->get('database')->execute('UPDATE faq_questions SET num_views = num_views + 1 WHERE id = ?', array((int) $id));
    }

Usage Example

Beispiel #1
0
 /**
  * Update the view count for this item
  */
 private function updateStatistics()
 {
     // view has been counted
     if (\SpoonSession::exists('viewed_faq_' . $this->record['id'])) {
         return;
     }
     // update view count
     FrontendFaqModel::increaseViewCount($this->record['id']);
     // save in session so we know this view has been counted
     \SpoonSession::set('viewed_faq_' . $this->record['id'], true);
 }