function NodeStatisticsDatabaseStorage::fetchAll

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

File

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

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.