statistics_get

5 statistics.module statistics_get($nid)
6 statistics.module statistics_get($nid)
7 statistics.module statistics_get($nid)
8 statistics.module statistics_get($nid)

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.

4 calls to statistics_get()

File

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

Code

function statistics_get($nid) {

  if ($nid > 0) {
    // Retrieve an array with both totalcount and daycount.
    return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
  }
}
Login or register to post comments