You are here

function ad_update_1 in Advertisement 5

Same name and namespace in other branches
  1. 5.2 ad.install \ad_update_1()

Introduce fields for specifying an optional maximum number of view or clicks for each ad. Also introduce fields for tracking the last time the ad was activated or expired.

File

./ad.install, line 274

Code

function ad_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'pgsql':
      db_add_column($ret, 'ads', 'activated', 'int', array(
        'not null' => TRUE,
        'default' => "'0'",
      ));
      db_add_column($ret, 'ads', 'maxviews', 'int', array(
        'not null' => TRUE,
        'default' => "'0'",
      ));
      db_add_column($ret, 'ads', 'maxclicks', 'int', array(
        'not null' => TRUE,
        'default' => "'0'",
      ));
      db_add_column($ret, 'ads', 'expired', 'int', array(
        'not null' => TRUE,
        'default' => "'0'",
      ));
      break;
    case 'mysql':
    case 'mysqli':
    default:
      $ret[] = update_sql("ALTER TABLE {ads} ADD activated INT UNSIGNED NOT NULL DEFAULT '0' AFTER autoexpired");
      $ret[] = update_sql("ALTER TABLE {ads} ADD maxviews INT UNSIGNED NOT NULL DEFAULT '0' AFTER activated");
      $ret[] = update_sql("ALTER TABLE {ads} ADD maxclicks INT UNSIGNED NOT NULL DEFAULT '0' AFTER maxviews");
      $ret[] = update_sql("ALTER TABLE {ads} ADD expired INT UNSIGNED NOT NULL DEFAULT '0' AFTER maxclicks");
  }
  return $ret;
}