From f87e1de3ec0b199a48818f84bdef4cdf34b50244 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 26 Feb 2009 15:02:04 +0000 Subject: Implement a random image block for the side bar. Ticket #13 --- .../image_block/helpers/image_block_installer.php | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 modules/image_block/helpers/image_block_installer.php (limited to 'modules/image_block/helpers/image_block_installer.php') diff --git a/modules/image_block/helpers/image_block_installer.php b/modules/image_block/helpers/image_block_installer.php new file mode 100644 index 00000000..6b0ec20b --- /dev/null +++ b/modules/image_block/helpers/image_block_installer.php @@ -0,0 +1,42 @@ +query("ALTER TABLE `items` ADD `rand_key` FLOAT DEFAULT NULL"); + $db->query("UPDATE `items` SET `rand_key` = RAND()"); + $db->query("CREATE INDEX `random_index` ON `items` (rand_key DESC)"); + + module::set_version("image_block", 1); + } + } + + static function uninstall() { + $db = Database::instance(); + // Dropping the column should drop the index as well. + $db->query("ALTER TABLE `items` DROP `rand_key`"); + + module::delete("image_block"); + } +} -- cgit v1.2.3