statistics_get($nid)
Retrieves a node's "view statistics".
Parameters
int $nid: The node ID.
Return value
array 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
- core/modules/statistics/statistics.module, line 141
- Logs and displays content statistics for a site.
Code
1 2 3 4 5 6 7 | 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' => 'replica' ))->fetchAssoc(); } } |
Please login to continue.