function faq_install in Frequently Asked Questions 5.2
Same name and namespace in other branches
- 8 faq.install \faq_install()
- 5 faq.install \faq_install()
- 6 faq.install \faq_install()
- 7 faq.install \faq_install()
Implementation of hook_install().
Inserts the FAQ module's schema in the SQL database.
File
- ./
faq.install, line 13 - FAQ module install file.
Code
function faq_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$created1 = db_query("CREATE TABLE IF NOT EXISTS {faq_weights} (\n tid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n nid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n weight TINYINT(4) NOT NULL DEFAULT '0',\n PRIMARY KEY (tid, nid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
$created2 = db_query("CREATE TABLE IF NOT EXISTS {faq_questions} (\n nid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n vid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n question text NOT NULL,\n PRIMARY KEY (nid, vid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$created1 = 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)
);');
$created2 = db_query('CREATE TABLE {faq_questions} (
nid integer NOT NULL DEFAULT 0,
vid integer NOT NULL DEFAULT 0,
question text NOT NULL,
PRIMARY KEY (nid, vid)
);');
break;
}
if (!$created1 || !$created2) {
drupal_set_message(t('Table installation for the FAQ module was unsuccessful.'), 'error');
}
}