function statistics_get
statistics_get($nid)
Retrieves a node's "view statistics".
Parameters
$nid: The node ID.
Return value
An associative array containing:
- totalcount: Integer for the total number of times the node has been viewed.
- daycount: Integer for the total number of times the node has been viewed "today". For the daycount to be reset, cron must be enabled.
- timestamp: Integer for the timestamp of when the node was last viewed.
File
- modules/statistics/statistics.module, line 316
- Logs and displays access statistics for a 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(); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!statistics!statistics.module/function/statistics_get/7.x