summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/albums.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/controllers/albums.php b/core/controllers/albums.php
index adf9a282..41a7810d 100644
--- a/core/controllers/albums.php
+++ b/core/controllers/albums.php
@@ -65,8 +65,10 @@ class Albums_Controller extends Items_Controller {
$template->set_global("parents", $album->parents());
$template->content = new View("album.html");
- $album->view_count++;
- $album->save();
+ // We can't use math in ORM or the query builder, so do this by hand. It's important
+ // that we do this with math, otherwise concurrent accesses will damage accuracy.
+ Database::instance()->query(
+ "UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id");
print $template;
}