You are here

function ad_statistics_increment in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 ad.module \ad_statistics_increment()
  2. 5 ad.module \ad_statistics_increment()
  3. 6 ad.module \ad_statistics_increment()
  4. 6.2 ad.module \ad_statistics_increment()
  5. 7 ad.module \ad_statistics_increment()

Increment action counter.

6 calls to ad_statistics_increment()
adserve_cache_increment in ./adcache.inc
Increment action directly in the database.
ad_cache_file_build in cache/file/ad_cache_file.module
Build all required cache files when using the file cache.
ad_cron in ./ad.module
Implementation of hook_cron().
ad_nodeapi in ./ad.module
Implementation of hook_nodeapi().
ad_operations_callback in ./ad.admin.inc
Callback function for admin mass approving ads. TODO: Update activated and expired when appropriate. TODO: Publish/unpublish nodes when appropriate.

... See full list

File

./ad.module, line 247

Code

function ad_statistics_increment($aid, $action, $group = NULL, $hostid = NULL) {

  // Update action statistics.
  db_query("UPDATE {ad_statistics} SET count = count + 1 WHERE date = %d AND aid = %d AND action = '%s' AND adgroup = '%s' AND hostid = '%s'", date('YmdH'), $aid, $action, $group, $hostid);

  // If column doesn't already exist, we need to add it.
  if (!db_affected_rows()) {
    db_query("INSERT INTO {ad_statistics} (aid, adgroup, hostid, date, action, count) VALUES(%d, '%s', '%s', %d, '%s', 1)", $aid, $group, $hostid, date('YmdH'), $action);

    // If another process already added this row our INSERT will fail, if so we
    // still need to increment it so we don't loose an action.
    if (!db_affected_rows()) {
      db_query("UPDATE {ad_statistics} SET count = count + 1 WHERE date = %d AND aid = %d AND action = '%s' AND adgroup = '%s' AND hostid = '%s'", date('YmdH'), $aid, $action, $group, $hostid);
    }
  }
  $event = array(
    'aid' => $aid,
    'action' => $action,
    'hostid' => $hostid,
  );
  module_invoke_all('adapi', 'statistics_increment', $event);
}