Same name and namespace in other branches
  1. 4.6.x modules/statistics.module \statistics_get()
  2. 4.7.x modules/statistics.module \statistics_get()
  3. 5.x modules/statistics/statistics.module \statistics_get()
  4. 7.x modules/statistics/statistics.module \statistics_get()
  5. 8.9.x core/modules/statistics/statistics.module \statistics_get()

Retrieves a node's "view statistics".

Parameters

$nid: node ID

Return value

An array with three entries: [0]=totalcount, [1]=daycount, [2]=timestamp

  • totalcount: count of the total number of times that node has been viewed.
  • daycount: count of the total number of times that node has been viewed "today". For the daycount to be reset, cron must be enabled.
  • timestamp: timestamp of when that node was last viewed.
1 call to statistics_get()
statistics_link in modules/statistics/statistics.module
Implementation of hook_link().

File

modules/statistics/statistics.module, line 230
Logs access statistics for your site.

Code

function statistics_get($nid) {
  if ($nid > 0) {

    // Retrieve an array with both totalcount and daycount.
    $statistics = db_fetch_array(db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = %d', $nid));
  }
  return $statistics;
}