function NodeStatisticsDatabaseStorage::fetchAll

Same name and namespace in other branches
  1. 10 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::fetchAll()
  2. 8.9.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::fetchAll()

File

core/modules/statistics/src/NodeStatisticsDatabaseStorage.php, line 95

Class

NodeStatisticsDatabaseStorage
Provides the default database storage backend for statistics.

Namespace

Drupal\statistics

Code

public function fetchAll($order = 'totalcount', $limit = 5) {
  assert(in_array($order, [
    'totalcount',
    'daycount',
    'timestamp',
  ]), "Invalid order argument.");
  return $this->connection
    ->select('node_counter', 'nc')
    ->fields('nc', [
    'nid',
  ])
    ->orderBy($order, 'DESC')
    ->range(0, $limit)
    ->execute()
    ->fetchCol();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.