summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-07-29 10:55:56 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-07-29 10:55:56 -0700
commit653c291d94f02e3e292541fe39d9fc95bf3d22ba (patch)
tree07f16fd32cf30507b71123bb86bcc072c3b1fa00 /modules/gallery/helpers
parent5a677975d044f088677d00d04c8e0ff5e3254959 (diff)
Fix for ticket #576
Add a weight index to the item table and changed the retrieval of the maximum weight to select weight from items order by weight desc limit 1. Upgrades the gallery module to version 10
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_installer.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 760bec31..2322110e 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -98,9 +98,20 @@ class gallery_installer {
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`),
KEY `type` (`type`),
- KEY `random` (`rand_key`))
+ KEY `random` (`rand_key`),
+ KEY `weight` (`weight` DESC))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("DELIMITER |
+ CREATE TRIGGER setweight BEFORE INSERT ON {items}
+ FOR EACH ROW BEGIN
+ DECLARE new_weight int(9);
+ SELECT weight+1 FROM {items}
+ ORDER BY weight LIMIT 1 INTO new_weight;
+ SET NEW.weight = new_weight;
+ END;|
+ DELIMITER ;");
+
$db->query("CREATE TABLE {logs} (
`id` int(9) NOT NULL auto_increment,
`category` varchar(64) default NULL,
@@ -329,7 +340,13 @@ class gallery_installer {
$db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
module::set_version("gallery", $version = 9);
}
- }
+
+ if ($version == 9) {
+ $db->query("ALTER TABLE {items} ADD KEY `weight` (`weight` DESC);");
+
+ module::set_version("gallery", $version = 10);
+ }
+}
static function uninstall() {
$db = Database::instance();