You are here

quicktabs.install in Quick Tabs 5

File

quicktabs.install
View source
<?php

function quicktabs_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {quicktabs} (\n        qtid int(10) unsigned NOT NULL default '0',\n        title varchar(255) NOT NULL default '',\n        tabs mediumtext NOT NULL,\n        PRIMARY KEY (qtid)\n        ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      $success = TRUE;
      break;
    case 'pgsql':
      db_query("CREATE TABLE {quicktabs} (\n        qtid int_unsigned NOT NULL default '0',\n        title varchar(255) NOT NULL default '',\n        tabs text NOT NULL,\n        PRIMARY KEY (qtid) \n        )");
      db_query('CREATE SEQUENCE {quicktabs}_seq');
      $success = TRUE;
      break;
    default:
      drupal_set_message(t('Unsupported database'));
  }
  if ($success) {
    drupal_set_message(t('Module tables installed successfully'));
  }
  else {
    drupal_set_message(t('Module installation was unsuccessful'), 'error');
  }
}
function quicktabs_uninstall() {
  if (db_table_exists('quicktabs')) {
    db_query("DROP TABLE {quicktabs}");
  }

  // Delete any variables that have been set.
  // We don't just DELETE FROM {variable}, even though we could.
  $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'quicktabs_%'");

  // Instead we use the API, because API's can change!
  while ($row = db_fetch_object($result)) {
    variable_del($row->name);
  }
}