summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/module.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-12-17 21:16:51 -0800
committerBharat Mediratta <bharat@menalto.com>2009-12-17 21:16:51 -0800
commit9d19e272d672ffc224dfed2799f8e480ecb583e4 (patch)
tree198ee5c3434b71341fb419f3399ad441a363b3ee /modules/gallery/helpers/module.php
parent8883d1605a12b94fb8f8b5a39ce5b4675b358302 (diff)
Convert some database queries.
Diffstat (limited to 'modules/gallery/helpers/module.php')
-rw-r--r--modules/gallery/helpers/module.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index b8928f7b..71c4efa0 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -432,17 +432,30 @@ class module_Core {
/**
* Increment the value of a variable for this module
+ *
+ * Note: Frequently updating counters is very inefficient because it invalidates the cache value
+ * which has to be rebuilt every time we make a change.
+ *
+ * @todo Get rid of this and find an alternate approach for all callers (currently only Akismet)
+ *
+ * @deprecated
* @param string $module_name
* @param string $name
* @param string $increment (optional, default is 1)
*/
static function incr_var($module_name, $name, $increment=1) {
- Database::instance()->query(
- "UPDATE {vars} SET `value` = `value` + $increment " .
- "WHERE `module_name` = '$module_name' " .
- "AND `name` = '$name'");
+ db::build()
+ ->update("vars")
+ ->set("value", new Database_Expression("`value` + $increment"))
+ ->where("module_name", "=", $module_name)
+ ->where("name", "=", $name)
+ ->execute();
- Database::instance()->delete("vars", array("module_name" => "gallery", "name" => "_cache"));
+ db::build()
+ ->delete("vars")
+ ->where("module_name", "=", "gallery")
+ ->where("name", "=", "_cache")
+ ->execute();
self::$var_cache = null;
}