You are here

function uc_addresses_install in Ubercart Addresses 5

Same name and namespace in other branches
  1. 5.2 uc_addresses.install \uc_addresses_install()
  2. 6.2 uc_addresses.install \uc_addresses_install()
  3. 6 uc_addresses.install \uc_addresses_install()
  4. 7 uc_addresses.install \uc_addresses_install()

Implementation of hook_install().

File

./uc_addresses.install, line 6

Code

function uc_addresses_install() {
  drupal_set_message(t('Beginning installation of uc_addresses module.'));
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {uc_addresses} (\n\taid integer unsigned not null,\n        uid integer unsigned not null,\n        first_name varchar(32) not null,\n        last_name varchar(32) not null,\n        phone varchar(32) not null,\n        company varchar(64) not null,\n        street1 varchar(64) not null,\n        street2 varchar(64) not null,\n        city varchar(32) not null,\n        zone mediumint(9) not null,\n        postal_code varchar(10) not null,\n        country mediumint(9) not null,\n\taddress_name varchar(20),\n        created int(11) not null,\n        modified int(11) not null,\n        PRIMARY KEY (aid),\n\tINDEX aid_uid_idx (aid, uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {uc_addresses_defaults} (\n\taid integer unsigned not null,\n        uid integer unsigned not null,\n        PRIMARY KEY (aid, uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      $success = TRUE;
      break;
    case 'pgsql':
      db_query("CREATE TABLE {uc_addresses} (\n\taid integer not null default 0,\n        uid integer not null default 0,\n        first_name varchar(32) not null default '',\n        last_name varchar(32) not null default '',\n        phone varchar(32) not null default '',\n        company varchar(64) not null default '',\n        street1 varchar(64) not null default '',\n        street2 varchar(64) not null default '',\n        city varchar(32) not null default '',\n        zone integer not null default 0,\n        postal_code varchar(10) not null default '',\n        country integer not null default 0,\n\taddress_name varchar(20) default '',\n        created integer not null default 0,\n        modified integer not null default 0,\n        PRIMARY KEY (aid)\n      );");
      db_query("CREATE INDEX {uc_addresses}_aid_uid_idx ON {uc_addresses} (aid, uid)");
      db_query("CREATE TABLE {uc_addresses_defaults} (\n\taid integer not null default 0,\n        uid integer not null default 0,\n        PRIMARY KEY (aid, uid)\n      );");
      $success = TRUE;
      break;
    default:
      drupal_set_message(t('Unsupported database.'));
  }
  if ($success) {
    drupal_set_message(t('The uc_addresses table was installed successfully.'));
  }
  else {
    drupal_set_message(t('The installation of the uc_addresses module was unsuccessful.'), 'error');
  }
}