You are here

function mediafront_statistics_increment_node_counter in MediaFront 6

Same name and namespace in other branches
  1. 6.2 plugins/mediafront_statistics/mediafront_statistics.module \mediafront_statistics_increment_node_counter()

Increments the node counter.

1 string reference to 'mediafront_statistics_increment_node_counter'
mediafront_statistics_service in plugins/mediafront_statistics/mediafront_statistics.module
Implementation of hook_service()

File

plugins/mediafront_statistics/mediafront_statistics.module, line 25

Code

function mediafront_statistics_increment_node_counter($nid) {
  if ($nid) {
    db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), $nid);
    if (!db_affected_rows()) {
      db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', $nid, time());
    }
    return db_result(db_query("SELECT totalcount FROM {node_counter} WHERE nid=%d", $nid));
  }
  else {
    return 0;
  }
}