Update some database calls.
This commit is contained in:
parent
fb36d5454c
commit
90ef5daa49
@ -102,7 +102,11 @@ class Json_Album_Controller extends Controller {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($album->children() as $child) {
|
foreach ($album->children() as $child) {
|
||||||
// Do this directly in the database to avoid sending notifications
|
// 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_column = "weight";
|
||||||
$album->sort_order = "ASC";
|
$album->sort_order = "ASC";
|
||||||
@ -118,15 +122,20 @@ class Json_Album_Controller extends Controller {
|
|||||||
|
|
||||||
// Make a hole
|
// Make a hole
|
||||||
$count = count($source_ids);
|
$count = count($source_ids);
|
||||||
Database::Instance()->query(
|
db::build()
|
||||||
"UPDATE {items} " .
|
->update("items")
|
||||||
"SET `weight` = `weight` + $count " .
|
->set("weight", new Database_Expression("`weight` + $count"))
|
||||||
"WHERE `weight` >= $target_weight AND `parent_id` = {$album->id}");
|
->where("weight", ">=", $target_weight)
|
||||||
|
->where("parent_id", "=", $album->id)
|
||||||
|
->execute();
|
||||||
|
|
||||||
// Insert source items into the hole
|
// Insert source items into the hole
|
||||||
foreach ($source_ids as $source_id) {
|
foreach ($source_ids as $source_id) {
|
||||||
Database::Instance()->update(
|
db::build()
|
||||||
"items", array("weight" => $target_weight++), array("id" => $source_id));
|
->update("items")
|
||||||
|
->set("weight", $target_weight++)
|
||||||
|
->where("id", "=", $source_id)
|
||||||
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
module::event("album_rearrange", $album);
|
module::event("album_rearrange", $album);
|
||||||
|
Reference in New Issue
Block a user