From d2cb217e20d44d7928a0910ac0375740de163bb3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 2 Dec 2009 00:34:34 -0800 Subject: Convert more database calls over to the new format - admin/maintenance page loads, the rebuild thumbs/resizes task works - Fixed up some conversion bugs in the Cache driver --- modules/gallery/helpers/graphics.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'modules/gallery/helpers/graphics.php') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index c93cc304..6fab0b54 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -197,11 +197,22 @@ class graphics_Core { * @return Database_Result Query result */ static function find_dirty_images_query() { - return Database::instance()->query( - "SELECT `id` FROM {items} " . - "WHERE ((`thumb_dirty` = 1 AND (`type` <> 'album' OR `album_cover_item_id` IS NOT NULL))" . - " OR (`resize_dirty` = 1 AND `type` = 'photo')) " . - " AND `id` != 1"); + return db::build() + ->from("items") + ->and_open() + ->and_open() + ->where("thumb_dirty", "=", 1) + ->and_open() + ->where("type", "<>", "album") + ->or_where("album_cover_item_id", "IS NOT", null) + ->close() + ->or_open() + ->where("resize_dirty", "=", 1) + ->where("type", "=", "photo") + ->close() + ->close() + ->where("id", "<>", 1) + ->close(); } /** @@ -209,18 +220,18 @@ class graphics_Core { */ static function mark_dirty($thumbs, $resizes) { if ($thumbs || $resizes) { - $db = Database::instance(); - $fields = array(); + $db = db::build() + ->update("items"); if ($thumbs) { - $fields["thumb_dirty"] = 1; + $db->set("thumb_dirty", 1); } if ($resizes) { - $fields["resize_dirty"] = 1; + $db->set("resize_dirty", 1); } - $db->update("items", $fields, true); + $db->execute(); } - $count = self::find_dirty_images_query()->count(); + $count = self::find_dirty_images_query()->count_records(); if ($count) { site_status::warning( t2("One of your photos is out of date. Click here to fix it", -- cgit v1.2.3