You are here

function imagecache_install in ImageCache 5.2

Same name and namespace in other branches
  1. 5 imagecache.install \imagecache_install()
  2. 6.2 imagecache.install \imagecache_install()

File

./imagecache.install, line 58

Code

function imagecache_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret1 = db_query("CREATE TABLE {imagecache_preset} (\n            presetid INT UNSIGNED NOT NULL PRIMARY KEY,\n            presetname VARCHAR(255) NOT NULL DEFAULT '' )\n            /*!40100 DEFAULT CHARACTER SET utf8 */\n      ");
      $ret2 = db_query("CREATE TABLE {imagecache_action} (\n            actionid INT UNSIGNED NOT NULL PRIMARY KEY,\n            presetid INT UNSIGNED NOT NULL DEFAULT 0,\n            weight INT NOT NULL DEFAULT 0,\n            module varchar(255) not null default '',\n            action varchar(255) not null default '',\n            data TEXT NOT NULL)\n            /*!40100 DEFAULT CHARACTER SET utf8 */\n      ");
      break;
    case 'pgsql':
      $ret1 = db_query("CREATE TABLE {imagecache_preset} (\n            presetid INTEGER NOT NULL CHECK (presetid > 0),\n            presetname VARCHAR(255) NOT NULL DEFAULT '',\n            PRIMARY KEY (presetid));\n      ");
      $ret2 = db_query("CREATE TABLE {imagecache_action} (\n            actionid INTEGER NOT NULL CHECK (actionid > 0),\n            presetid INTEGER NOT NULL DEFAULT 0,\n            weight INTEGER NOT NULL DEFAULT 0,\n            module varchar(255) not null default '',\n            action varchar(255) not null default '',\n            data TEXT NOT NULL DEFAULT '',\n            PRIMARY KEY (actionid));\n      ");
      db_query("CREATE SEQUENCE {imagecache_preset}_presetid_seq INCREMENT 1 START 1;");
      db_query("CREATE SEQUENCE {imagecache_action}_actionid_seq INCREMENT 1 START 1;");
      break;
  }
  if ($ret1 && $ret2) {
    drupal_set_message(t('Imagecache module installed succesfully.'));
  }
  else {
    drupal_set_message(t('Imagecache module installation was unsuccessfull. Necessary database tables should be created by hand.', 'error'));
  }
  return $ret;
}