From ca96d4719608d4a8a62457ecf3e54ac8ca29629a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 29 Jul 2009 16:58:29 -0700 Subject: 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. --- modules/gallery/models/item.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modules/gallery/models') 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; } -- cgit v1.2.3