similarterms.install in Similar By Terms 5
Same filename and directory in other branches
Similar By Terms install file
File
similarterms.installView source
<?php
/**
* @file
* Similar By Terms install file
*/
/**
* Implementation of hook_install().
*/
function similarterms_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$result = db_query("CREATE TABLE {cache_similarterms} (\n cid varchar(255) NOT NULL default '',\n data longblob,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid),\n INDEX expire (expire)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
$result2 = db_query("CREATE TABLE IF NOT EXISTS {similarterms_override} (\n nid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n path INT(10) UNSIGNED NOT NULL,\n vid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n KEY (nid),\n KEY (vid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$result = db_query("CREATE TABLE {cache_similarterms} (\n cid varchar(255) NOT NULL default '',\n data bytea,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid)\n )");
db_query("CREATE INDEX {cache_similarterms}_expire_idx ON {cache_similarterms} (expire)");
$result2 = db_query("CREATE TABLE {similarterms_override} (\n nid int NOT NULL default '0',\n path int NOT NULL,\n vid int NOT NULL default '0'\n )");
db_query("CREATE INDEX {similarterms_override}_nid_idx ON {similarterms_override} (nid)");
db_query("CREATE INDEX {similarterms_override}_vid_idx ON {similarterms_override} (vid)");
break;
}
if (!$result || !$result2) {
drupal_set_message(t('The table similar by terms was not installed properly. Please investigate.', 'error'));
}
}
/**
* Implementation of hook_uninstall().
*/
function similarterms_uninstall() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$deleted = db_query('DROP TABLE IF EXISTS {cache_similarterms}');
$deleted2 = db_query('DROP TABLE IF EXISTS {similarterms_override}');
break;
case 'pgsql':
$deleted = db_query('DROP TABLE {cache_similarterms}');
$deleted2 = db_query('DROP TABLE {similarterms_override}');
break;
}
}
/**
* Implementation of hook_update().
*/
function similarterms_update_5001() {
$return = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$return[] = update_sql("CREATE TABLE {cache_similarterms} (\n cid varchar(255) NOT NULL default '',\n data longblob,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid),\n INDEX expire (expire)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
$return[] = update_sql("CREATE TABLE IF NOT EXISTS {similarterms_override} (\n nid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n path INT(10) UNSIGNED NOT NULL,\n vid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n KEY (nid),\n KEY(vid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$return[] = update_sql("CREATE TABLE {cache_similarterms} (\n cid varchar(255) NOT NULL default '',\n data bytea,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid)\n )");
$return[] = update_sql("CREATE INDEX {cache_similarterms}_expire_idx ON {cache_similarterms} (expire)");
$return[] = update_sql("CREATE TABLE {similarterms_override} (\n nid int NOT NULL DEFAULT '0',\n path int NOT NULL,\n vid int NOT NULL DEFAULT '0'\n )");
$return[] = update_sql("CREATE INDEX {similarterms_override}_nid_idx ON {similarterms_override} (nid)");
$return[] = update_sql("CREATE INDEX {similarterms_override}_vid_idx ON {similarterms_override} (vid)");
break;
}
return $return;
}
Functions
Name | Description |
---|---|
similarterms_install | Implementation of hook_install(). |
similarterms_uninstall | Implementation of hook_uninstall(). |
similarterms_update_5001 | Implementation of hook_update(). |