ad_image.install in Advertisement 5
File
image/ad_image.install
View source
<?php
function ad_image_install() {
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_query("CREATE TABLE {ad_image_format} (\n gid INT NOT NULL UNIQUE PRIMARY KEY,\n\n min_width INT NOT NULL DEFAULT '0',\n max_width INT NOT NULL DEFAULT '0',\n min_height INT NOT NULL DEFAULT '0',\n max_height INT NOT NULL DEFAULT '0'\n );");
db_query("CREATE TABLE {ad_image} (\n aid INT NOT NULL DEFAULT '0' UNIQUE,\n fid INT NOT NULL DEFAULT '0',\n \n url VARCHAR(255) NOT NULL DEFAULT '',\n tooltip VARCHAR(255) NOT NULL DEFAULT '',\n width INT NOT NULL DEFAULT '0',\n height INT NOT NULL DEFAULT '0'\n );");
break;
case 'mysql':
case 'mysqli':
default:
db_query("CREATE TABLE {ad_image_format} (\n gid INT(10) UNSIGNED NOT NULL,\n\n min_width INT(5) UNSIGNED NOT NULL DEFAULT '0',\n max_width INT(5) UNSIGNED NOT NULL DEFAULT '0',\n min_height INT(5) UNSIGNED NOT NULL DEFAULT '0',\n max_height INT(5) UNSIGNED NOT NULL DEFAULT '0',\n\n PRIMARY KEY (gid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {ad_image} (\n aid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n fid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n\n url VARCHAR(255) NOT NULL DEFAULT '',\n tooltip VARCHAR(255) NOT NULL DEFAULT '',\n width INT UNSIGNED NOT NULL DEFAULT '0',\n height INT UNSIGNED NOT NULL DEFAULT '0',\n\n UNIQUE KEY (aid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
}
drupal_set_message(t('The necessary ad_image module tables have been created.'));
}
function ad_image_uninstall() {
$result = db_query("SELECT aid FROM {ad_image}");
while ($aid = db_result($result)) {
node_delete($aid);
}
db_query('DROP TABLE {ad_image}');
db_query('DROP TABLE {ad_image_format}');
}
function ad_image_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {ad_image} ADD tooltip VARCHAR(255) NOT NULL DEFAULT ''");
break;
default:
$ret[] = update_sql("ALTER TABLE {ad_image} ADD tooltip VARCHAR(255) NOT NULL DEFAULT '' AFTER url");
}
return $ret;
}
function ad_image_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
break;
default:
$tables = array(
'ad_image',
'ad_image_format',
);
foreach ($tables as $table) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} CONVERT TO CHARACTER SET utf8');
}
}
return $ret;
}