function customfilter_install in Custom filter 5
Same name and namespace in other branches
- 6.2 customfilter.install \customfilter_install()
- 6 customfilter.install \customfilter_install()
- 7.2 customfilter.install \customfilter_install()
- 7 customfilter.install \customfilter_install()
Implements hook_install()
File
- ./
customfilter.install, line 6
Code
function customfilter_install() {
$result = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$result[] = db_query("CREATE TABLE {customfilter_set} (\n `sid` int(10) unsigned NOT NULL default '0',\n `name` varchar(32) NOT NULL default '',\n `cache` tinyint(1) NOT NULL default '1',\n `description` text,\n `shorttips` text,\n `longtips` text,\n PRIMARY KEY(sid) \n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
$result[] = db_query("CREATE TABLE {customfilter_filter} (\n `fid` int(10) unsigned NOT NULL default '0',\n `sid` int(10) unsigned NOT NULL default '0',\n `parentid` int(10) unsigned NOT NULL default '0',\n `name` varchar(32) NOT NULL default '',\n `description` text,\n `matches` int(2) NOT NULL default '1',\n `pattern` text,\n `replacement` text,\n `func` tinyint(1) NOT NULL default '0',\n `weight` int(5) NOT NULL default '0',\n PRIMARY KEY(fid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
break;
case 'pgsql':
$result[] = db_query("CREATE TABLE {customfilter_set} (\n sid serial,\n name varchar(32) NOT NULL default '',\n cache smallint NOT NULL default '1',\n description text,\n shorttips text,\n longtips text,\n PRIMARY KEY(sid) \n )");
$result[] = db_query("CREATE TABLE {customfilter_filter} (\n fid serial,\n sid int_unsigned NOT NULL default '0',\n parentid int_unsigned NOT NULL default '0',\n name varchar(32) NOT NULL default '',\n description text,\n matches smallint NOT NULL default '1',\n pattern text,\n replacement text,\n func smallint NOT NULL default '0',\n weight int NOT NULL default '0',\n PRIMARY KEY(fid)\n )");
break;
}
if (count($result) == count(array_filter($result))) {
drupal_set_message(t('The CustomFilter module has successfully added its tables to the database.'));
}
else {
drupal_set_message(t('Drupal was unable to install the database tables for the CustomFilter module.'), 'error');
}
}