Update to image_block based on bharat's feedback

1) move the rand_key column into core
2) don't do a max rand, just try to a get a random number less than
the current random number if that doesn't successd look the other way
This commit is contained in:
Tim Almdal
2009-02-26 23:38:17 +00:00
parent 960c4248de
commit d097b4fc02
8 changed files with 17 additions and 47 deletions
@@ -24,18 +24,12 @@ class image_block_installer {
if ($version == 0) {
$db = Database::instance();
$db->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");
}