You are here

function mobile_codes_install in Mobile Codes 5

Same name and namespace in other branches
  1. 6.2 mobile_codes.install \mobile_codes_install()
  2. 6 mobile_codes.install \mobile_codes_install()

@file

File

./mobile_codes.install, line 8

Code

function mobile_codes_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {mobile_codes} (\n        pid INT UNSIGNED NOT NULL,\n        data TEXT NOT NULL DEFAULT '',\n        file VARCHAR(255) NOT NULL PRIMARY KEY)\n        /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE {mobile_codes_presets} (\n        pid SERIAL NOT NULL PRIMARY KEY,\n        name VARCHAR(255) NOT NULL,\n        data TEXT NOT NULL)\n        /*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {mobile_codes} (\n        pid INTEGER NOT NULL DEFAULT 0,\n        data TEXT NOT NULL DEFAULT '',\n        file VARCHAR(255) PRIMARY KEY);");
      db_query("CREATE TABLE {mobile_codes_presets} (\n        pid INTEGER PRIMARY KEY CHECK (pid > 0),\n        name VARCHAR(255) NOT NULL DEFAULT '',\n        data TEXT NOT NULL DEFAULT '');");
      db_query("CREATE SEQUENCE {mobile_codes_preset_pid_seq} INCREMENT 1 START 1;");
      break;
  }
  db_query("INSERT INTO {mobile_codes_presets} (pid, name, data) VALUES (%d, '%s', '%s')", 1, 'Default', 'a:4:{s:4:"type";s:2:"qr";s:4:"data";s:4:"text";s:4:"size";s:1:"m";s:7:"tinyurl";i:0;}');
}