diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-07-29 10:55:56 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-07-29 10:55:56 -0700 |
commit | 653c291d94f02e3e292541fe39d9fc95bf3d22ba (patch) | |
tree | 07f16fd32cf30507b71123bb86bcc072c3b1fa00 /modules/gallery/models | |
parent | 5a677975d044f088677d00d04c8e0ff5e3254959 (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/models')
-rw-r--r-- | modules/gallery/models/item.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index dcbee991..481b22bc 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -350,9 +350,21 @@ class Item_Model extends ORM_MPTT { if (!empty($this->changed) && $this->changed != array("view_count" => "view_count")) { $this->updated = time(); if (!$this->loaded) { + try { $this->created = $this->updated; - $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find(); - $this->weight = $r->max_weight + 1; + Kohana::log("error", "get Weight"); + $weight = ORM::factory("item") + ->select("weight") + ->orderby("weight", "DESC") + ->limit(1) + ->find_all() + ->current()->weight; + Kohana::log("error", "Weight: $weight"); + $this->weight = $weight + 1; + } catch (Exception $e) { + Kohana::log("error", $e->__toString()); + throw $e; + } } else { $send_event = 1; } |