function ad_statistics_increment in Advertisement 5.2
Same name and namespace in other branches
- 5 ad.module \ad_statistics_increment()
- 6.3 ad.module \ad_statistics_increment()
- 6 ad.module \ad_statistics_increment()
- 6.2 ad.module \ad_statistics_increment()
- 7 ad.module \ad_statistics_increment()
Increment action counter.
9 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_cache_memcache_sync_ad in cache/
memcache/ ad_cache_memcache.module - Syncronize counts for given advertisement with database.
- ad_cron in ./
ad.module - Drupal _cron hook.
- ad_image_handler_field_image in image/
ad_image_views.inc
File
- ./
ad.module, line 268 - An advertising system for Drupal powered websites.
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);
}