mobile_codes.install in Mobile Codes 5
File
mobile_codes.install
View source
<?php
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;}');
}
function mobile_codes_uninstall() {
include_once drupal_get_path('module', 'mobile_codes') . '/mobile_codes.admin.inc';
db_query('DROP TABLE {mobile_codes}');
db_query('DROP TABLE {mobile_codes_presets}');
if ($GLOBALS['db_type'] == 'pgsql') {
db_query('DROP SEQUENCE {mobile_codes_preset_pid_seq};');
}
$dir = realpath(file_directory_path() . '/mobile_codes');
if (is_dir($dir)) {
_mobile_codes_recursive_delete($dir);
}
variable_del('mobile_codes_flush');
}