function NodeStatisticsDatabaseStorage::recordView
Same name in other branches
- 8.9.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::recordView()
- 10 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::recordView()
- 11.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::recordView()
Overrides StatisticsStorageInterface::recordView
File
-
core/
modules/ statistics/ src/ NodeStatisticsDatabaseStorage.php, line 54
Class
- NodeStatisticsDatabaseStorage
- Provides the default database storage backend for statistics.
Namespace
Drupal\statisticsCode
public function recordView($id) {
return (bool) $this->connection
->merge('node_counter')
->key('nid', $id)
->fields([
'daycount' => 1,
'totalcount' => 1,
'timestamp' => $this->getRequestTime(),
])
->expression('daycount', '[daycount] + 1')
->expression('totalcount', '[totalcount] + 1')
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.