You are here

function _ad_weight_probability_node_save in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 weight/probability/ad_weight_probability.module \_ad_weight_probability_node_save()
  2. 6.2 weight/probability/ad_weight_probability.module \_ad_weight_probability_node_save()
  3. 7 weight/probability/ad_weight_probability.module \_ad_weight_probability_node_save()

Helper function, save the probability to the database.

1 call to _ad_weight_probability_node_save()
ad_weight_probability_nodeapi in weight/probability/ad_weight_probability.module
Implementation of hook_nodeapi().

File

weight/probability/ad_weight_probability.module, line 115
A plug in for the ad.module, allowing an admin to set the probability that a given advertisement will be displayed.

Code

function _ad_weight_probability_node_save($node) {
  if (isset($node->nid) && $node->nid) {
    db_query('UPDATE {ad_weight_probability} SET probability = %d WHERE aid = %d', $node->probability, $node->nid);
    if (!db_affected_rows()) {
      db_query('INSERT INTO {ad_weight_probability} (aid, probability) VALUES(%d, %d)', $node->nid, $node->probability);
    }
  }
}