Statistics module doesn't update when getting a node I've created a custom module, which should regarding some other posts help updating the daycount. But it just doesn't get updated.

function services_statistics_improved_services_request_postprocess_alter($controller, $args, &amp;$result) {
      // Increment hit count for node view api requests.
      if($controller['callback'] == '_node_resource_retrieve') {
        $nid = $result-&gt;nid; // May need to confirm this is the node id.
        dpm($controller);
        // See statistics_exit()
        if (variable_get('statistics_count_content_views', 0)) {
          // A node has been requested, so update the node's counters.
          db_merge('node_counter')-&gt;key(array('nid' =&gt; $nid))-&gt;fields(array(
            'daycount' =&gt; 1,
            'totalcount' =&gt; 1,
            'weekcount' =&gt; 1,
            'monthcount' =&gt; 1,
            'yearcount' =&gt; 1,
            'timestamp' =&gt; REQUEST_TIME,
          ))
          -&gt;expression('daycount', 'daycount + 1')
          -&gt;expression('totalcount', 'totalcount + 1')
          -&gt;expression('weekcount', 'weekcount + 1')
          -&gt;expression('monthcount', 'monthcount + 1')
          -&gt;expression('yearcount', 'yearcount + 1')
          -&gt;execute();
        }
      }
    }


Anyone able to help me out here?
The query to update the node_counter table may need tuning.

e.g:

if (variable_get('statistics_count_content_views', 0)) {
  // A node has been served, so update the node counters.
  db_merge('node_counter')
    -&gt;key(array('nid' =&gt; $nid))
    -&gt;fields(array(
      'daycount' =&gt; 1,
      'totalcount' =&gt; 1,
      'timestamp' =&gt; REQUEST_TIME,
    ))
    -&gt;expression('daycount', 'daycount + 1')
    -&gt;expression('totalcount', 'totalcount + 1')
    -&gt;execute();
}


The other fields, such as 'yearcount' etc.. aren't in the node_counter, at least not by default which may be causing a PDOException there.