summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-12-25 13:24:38 -0800
committerBharat Mediratta <bharat@menalto.com>2009-12-25 13:24:38 -0800
commit07a9ef2276a421fe3b8ebad4c4ff845b147be847 (patch)
tree0828e3b03d680dea3eb695342ff0e65c85071250
parentc50c2d135c5e769e8904e5dc766d27bcd4a1d8b3 (diff)
Convert some database calls
-rw-r--r--modules/organize/controllers/organize.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 03dea13d..201ced30 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -75,7 +75,11 @@ class Organize_Controller extends Controller {
$i = 0;
foreach ($album->children() as $child) {
// Do this directly in the database to avoid sending notifications
- Database::Instance()->update("items", array("weight" => ++$i), array("id" => $child->id));
+ db::build()
+ ->update("items")
+ ->set("weight", ++$i)
+ ->where("id", "=", $child->id)
+ ->execute();
}
$album->sort_column = "weight";
$album->sort_order = "ASC";
@@ -91,15 +95,20 @@ class Organize_Controller extends Controller {
// Make a hole
$count = count($source_ids);
- Database::Instance()->query(
- "UPDATE {items} " .
- "SET `weight` = `weight` + $count " .
- "WHERE `weight` >= $target_weight AND `parent_id` = {$album->id}");
+ db::build()
+ ->update("items")
+ ->set("weight", new Database_Expression("`weight` + $count"))
+ ->where("weight", ">=", $target_weight)
+ ->where("parent_id", "=", $album->id)
+ ->execute();
// Insert source items into the hole
foreach ($source_ids as $source_id) {
- Database::Instance()->update(
- "items", array("weight" => $target_weight++), array("id" => $source_id));
+ db::build()
+ ->update("items")
+ ->set("weight", $target_weight++)
+ ->where("id", "=", $source_id)
+ ->execute();
}
module::event("album_rearrange", $album);