You are here

function faq_install in Frequently Asked Questions 5

Same name and namespace in other branches
  1. 8 faq.install \faq_install()
  2. 5.2 faq.install \faq_install()
  3. 6 faq.install \faq_install()
  4. 7 faq.install \faq_install()

Implementation of hook_install() just give a message

File

./faq.install, line 7

Code

function faq_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $created = db_query("CREATE TABLE IF NOT EXISTS {faq_weights} (\n        tid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n        nid INT(10) NOT NULL DEFAULT '0',\n        weight TINYINT(4) NOT NULL DEFAULT '0',\n        PRIMARY KEY (tid, nid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $created = db_query('CREATE TABLE {faq_weights} (
        tid integer NOT NULL DEFAULT 0,
        nid integer NOT NULL DEFAULT 0,
        weight smallint NOT NULL DEFAULT 0,
        PRIMARY KEY (tid, nid)
      );');
      break;
  }
  if ($created) {
    drupal_set_message(t('FAQ module installed successfully.'));
  }
  else {
    drupal_set_message(t('Table installation for the FAQ module was unsuccessful.'), 'error');
  }
}