You are here

browscap.install in Browscap 5

File

browscap.install
View source
<?php

/**
 * Implementation of hook_install()
 */
function browscap_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $queries = db_query("CREATE TABLE {browscap} (\n                  useragent varchar(255) NOT NULL default '',\n                  `data` longblob NOT NULL,\n                  PRIMARY KEY  (useragent)\n                  ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      $queries &= db_query("CREATE TABLE {browscap_statistics} (\n                  parent VARCHAR(255) NOT NULL,\n                  counter INT DEFAULT '0' NOT NULL,\n                  is_crawler TINYINT(1) DEFAULT '0' NOT NULL,\n                  PRIMARY KEY (parent)\n                ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      $queries &= db_query("CREATE TABLE {cache_browscap} (\n                  cid varchar(255) NOT NULL default '',\n                  `data` longblob,\n                  expire int(11) NOT NULL default '0',\n                  created int(11) NOT NULL default '0',\n                  headers text,\n                  PRIMARY KEY  (cid),\n                  KEY expire (expire)\n                  ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      if ($queries) {
        drupal_set_message(t('Browscap tables installed into the database'));
      }
      else {
        drupal_set_message(t('There was a problem installing the Browscap tables.'), 'error');
      }
      break;
    case 'pgsql':

      // This space available...
      break;
  }
}
function browscap_uninstall() {
  db_query('DROP TABLE {browscap_statistics}');
  db_query('DROP TABLE {browscap}');
  db_query('DROP TABLE {cache_browscap}');
  variable_del('browscap_monitor');
  variable_del('browscap_imported');
  variable_del('browscap_version');
}

/**
 * Updates existing tables to UTF-8.
 */
function browscap_update_1() {
  return _system_update_utf8(array(
    'browscap',
  ));
  return _system_update_utf8(array(
    'browscap_statistics',
  ));
}

Functions

Namesort descending Description
browscap_install Implementation of hook_install()
browscap_uninstall
browscap_update_1 Updates existing tables to UTF-8.