You are here

function ad_increase_denormalized_counter in Advertisement 7.3

Increase one of the denormalized counters of an ad by one.

Parameters

$nid: The ID of the affected ad.

$field: The field to increase: 'total_clicks' or 'total_impressions'.

2 calls to ad_increase_denormalized_counter()
ad_delayed_track_impression in ./ad.module
Worker callback to track the impression from the queue.
ad_track_event in ./ad.module
Track an event, like a click or an impression.

File

./ad.module, line 569
Core code for the ad module.

Code

function ad_increase_denormalized_counter($nid, $field) {

  // Denormalize these counters taking advantage of the properties of the base
  // table. This allows to be quick while still easily avoiding race conditions.
  $field = db_escape_field($field);
  db_query("\n    INSERT INTO {ad_node}\n    (nid, {$field})\n    VALUES (:nid, 1)\n    ON DUPLICATE KEY UPDATE {$field} = {$field} + 1\n  ", array(
    ':nid' => $nid,
  ));
}