summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-29 16:58:29 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-29 16:58:29 -0700
commitca96d4719608d4a8a62457ecf3e54ac8ca29629a (patch)
treec31b0d19d2686167fe314215992258e8d5ed4bde
parent9d2420e789cd02d459e7b1504b995bd9f4e84d00 (diff)
Oops, I removed too much in my last change. Put talmdal's query back,
but change it to use Database instead of ORM for a little more efficiency.
-rw-r--r--modules/gallery/models/item.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index dcbee991..a0598ea4 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -351,8 +351,11 @@ class Item_Model extends ORM_MPTT {
$this->updated = time();
if (!$this->loaded) {
$this->created = $this->updated;
- $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find();
- $this->weight = $r->max_weight + 1;
+ $weight = Database::instance()
+ ->select("weight")->from("items")
+ ->orderby("weight", "desc")->limit(1)
+ ->get()->current()->weight;
+ $this->weight = $weight + 1;
} else {
$send_event = 1;
}