View source
<?php
function memcache_install() {
$core = array(
'cache',
'cache_filter',
'cache_menu',
'cache_page',
);
$alltables = array_merge($core, module_invoke_all('devel_caches'));
switch ($GLOBALS['db_type']) {
case 'pgsql':
foreach ($alltables as $table) {
db_query("DELETE FROM {{$table}}");
db_query("ALTER TABLE {{$table}} ADD serialized smallint NOT NULL default '0'");
}
break;
case 'mysql':
case 'mysqli':
foreach ($alltables as $table) {
db_query("DELETE FROM {{$table}}");
db_query("ALTER TABLE {{$table}} ADD serialized int(1) NOT NULL default '0'");
}
break;
}
}
function memcache_uninstall() {
$core = array(
'cache',
'cache_filter',
'cache_menu',
'cache_page',
);
$alltables = array_merge($core, module_invoke_all('devel_caches'));
switch ($GLOBALS['db_type']) {
case 'pgsql':
case 'mysql':
case 'mysqli':
foreach ($alltables as $table) {
db_query("ALTER TABLE {{$table}} DROP serialized");
}
break;
}
}
function memcache_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_add_column($ret, 'cache', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
db_add_column($ret, 'cache_filter', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
db_add_column($ret, 'cache_page', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
db_add_column($ret, 'cache_menu', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
if (db_table_exists('cache_views')) {
db_add_column($ret, 'cache_views', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
}
if (db_table_exists('cache_blocks')) {
db_add_column($ret, 'cache_blocks', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
}
if (db_table_exists('cache_content')) {
db_add_column($ret, 'cache_content', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
}
if (db_table_exists('cache_reptag')) {
db_add_column($ret, 'cache_reptag', 'serialized', 'integer', array(
'default' => "'0'",
'not null' => TRUE,
));
}
break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {cache} ADD serialized int(1) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {cache_filter} ADD serialized int(1) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {cache_page} ADD serialized int(1) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {cache_menu} ADD serialized int(1) NOT NULL default '0'");
if (db_table_exists('cache_views')) {
$ret[] = update_sql("ALTER TABLE {cache_views} ADD serialized int(1) NOT NULL default '0'");
}
if (db_table_exists('cache_blocks')) {
$ret[] = update_sql("ALTER TABLE {cache_blocks} ADD serialized int(1) NOT NULL default '0'");
}
if (db_table_exists('cache_content')) {
$ret[] = update_sql("ALTER TABLE {cache_content} ADD serialized int(1) NOT NULL default '0'");
}
if (db_table_exists('cache_reptag')) {
$ret[] = update_sql("ALTER TABLE {cache_reptag} ADD serialized int(1) NOT NULL default '0'");
}
break;
}
return $ret;
}