mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-22 23:05:18 -04:00
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:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user