| 1 |
<?php
|
| 2 |
// $Id: memcache.install,v 1.4 2007/05/21 17:02:00 robertDouglass Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Add serialized field to cache tables.
|
| 6 |
*/
|
| 7 |
function memcache_install() {
|
| 8 |
$core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');
|
| 9 |
$alltables = array_merge($core, module_invoke_all('devel_caches'));
|
| 10 |
|
| 11 |
switch ($GLOBALS['db_type']) {
|
| 12 |
case 'pgsql':
|
| 13 |
foreach ($alltables as $table) {
|
| 14 |
db_add_column($ret, $table, 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 15 |
}
|
| 16 |
break;
|
| 17 |
case 'mysql':
|
| 18 |
case 'mysqli':
|
| 19 |
foreach ($alltables as $table) {
|
| 20 |
db_query("ALTER TABLE {$table} ADD serialized int(1) NOT NULL default '0'");
|
| 21 |
}
|
| 22 |
break;
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Remove serialized field from cache tables
|
| 28 |
*/
|
| 29 |
function memcache_uninstall() {
|
| 30 |
$core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');
|
| 31 |
$alltables = array_merge($core, module_invoke_all('devel_caches'));
|
| 32 |
|
| 33 |
switch ($GLOBALS['db_type']) {
|
| 34 |
case 'pgsql':
|
| 35 |
break;
|
| 36 |
case 'mysql':
|
| 37 |
case 'mysqli':
|
| 38 |
foreach ($alltables as $table) {
|
| 39 |
db_query("ALTER TABLE {$table} DROP serialized");
|
| 40 |
}
|
| 41 |
break;
|
| 42 |
}
|
| 43 |
}
|
| 44 |
|
| 45 |
/**
|
| 46 |
* Add serialized field to cache tables
|
| 47 |
*/
|
| 48 |
function memcache_update_1() {
|
| 49 |
$ret = array();
|
| 50 |
|
| 51 |
switch ($GLOBALS['db_type']) {
|
| 52 |
case 'pgsql':
|
| 53 |
db_add_column($ret, 'cache', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 54 |
db_add_column($ret, 'cache_filter', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 55 |
db_add_column($ret, 'cache_page', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 56 |
db_add_column($ret, 'cache_menu', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 57 |
if (db_table_exists('cache_views')) {
|
| 58 |
db_add_column($ret, 'cache_views', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 59 |
}
|
| 60 |
if (db_table_exists('cache_blocks')) {
|
| 61 |
db_add_column($ret, 'cache_blocks', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 62 |
}
|
| 63 |
if (db_table_exists('cache_content')) {
|
| 64 |
db_add_column($ret, 'cache_content', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 65 |
}
|
| 66 |
if (db_table_exists('cache_reptag')) {
|
| 67 |
db_add_column($ret, 'cache_reptag', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE));
|
| 68 |
}
|
| 69 |
break;
|
| 70 |
case 'mysql':
|
| 71 |
case 'mysqli':
|
| 72 |
$ret[] = update_sql("ALTER TABLE {cache} ADD serialized int(1) NOT NULL default '0'");
|
| 73 |
$ret[] = update_sql("ALTER TABLE {cache_filter} ADD serialized int(1) NOT NULL default '0'");
|
| 74 |
$ret[] = update_sql("ALTER TABLE {cache_page} ADD serialized int(1) NOT NULL default '0'");
|
| 75 |
$ret[] = update_sql("ALTER TABLE {cache_menu} ADD serialized int(1) NOT NULL default '0'");
|
| 76 |
if (db_table_exists('cache_views')) {
|
| 77 |
$ret[] = update_sql("ALTER TABLE {cache_views} ADD serialized int(1) NOT NULL default '0'");
|
| 78 |
}
|
| 79 |
if (db_table_exists('cache_blocks')) {
|
| 80 |
$ret[] = update_sql("ALTER TABLE {cache_blocks} ADD serialized int(1) NOT NULL default '0'");
|
| 81 |
}
|
| 82 |
if (db_table_exists('cache_content')) {
|
| 83 |
$ret[] = update_sql("ALTER TABLE {cache_content} ADD serialized int(1) NOT NULL default '0'");
|
| 84 |
}
|
| 85 |
if (db_table_exists('cache_reptag')) {
|
| 86 |
$ret[] = update_sql("ALTER TABLE {cache_reptag} ADD serialized int(1) NOT NULL default '0'");
|
| 87 |
}
|
| 88 |
|
| 89 |
break;
|
| 90 |
|
| 91 |
}
|
| 92 |
|
| 93 |
return $ret;
|
| 94 |
}
|