Search code examples
drupal-7

Drupal 7 : How can see number views of node


I'm using Drupal 7. After enabling the Statistics module, I see, under each node, how many times it has been read (e.g. "4 reads").

I need to knew where this views (e.g. "4 reads") save in table in database ?

I need to know where is saved to using it in my SQL


Solution

  • This data is stored in database table node_counter, field totalcount.

    You can use function statistics_get() to get the total number of times the node has been viewed.

    Example:

    // the node nid
    $nid = 1;
    // get the node statistics
    $node_stats = statistics_get($nid);
    // get the count of the node reads
    $node_reads = $node_stats['totalcount'];
    

    Or, if you need to access it directly with SQL code,

    SELECT totalcount FROM node_counter WHERE nid = 1;