function ad_statistics_increment in Advertisement 7
Same name and namespace in other branches
- 5.2 ad.module \ad_statistics_increment()
- 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()
Increment action counter.
5 calls to ad_statistics_increment()
- 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 - 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.
- ad_redirect in ./
ad.module - Update click counter then redirect host to ad's target URL.
File
- ./
ad.module, line 354
Code
function ad_statistics_increment($aid, $action, $group = NULL, $hostid = NULL) {
if (empty($hostid)) {
$hostid = ' ';
}
// Update action statistics.
$result = db_query("UPDATE {ad_statistics} SET count = count + 1 WHERE date = :date AND aid = :aid AND action = :action AND adgroup = :adgroup AND hostid = :hostid", array(
':date' => date('YmdH'),
':aid' => $aid,
':action' => $action,
':adgroup' => $group,
':hostid' => $hostid,
));
// If column doesn't already exist, we need to add it.
if (!$result
->rowCount()) {
$id = db_insert('ad_statistics')
->fields(array(
'aid' => $aid,
'adgroup' => $group,
'hostid' => $hostid,
'date' => date('YmdH'),
'action' => $action,
'count' => 1,
))
->execute();
// 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 (!$id) {
db_query("UPDATE {ad_statistics} SET count = count + 1 WHERE date = :date AND aid = :aid AND action = :action AND adgroup = :adgroup AND hostid = :hostid", array(
':date' => date('YmdH'),
':aid' => $aid,
':action' => $action,
':adgroup' => $group,
':hostid' => $hostid,
));
}
}
$event = array(
'aid' => $aid,
'action' => $action,
'hostid' => $hostid,
);
module_invoke_all('adapi', 'statistics_increment', $event);
}