diff options
| author | Chad Kieffer <ckieffer@gmail.com> | 2011-01-04 15:59:26 -0700 |
|---|---|---|
| committer | Chad Kieffer <ckieffer@gmail.com> | 2011-01-04 15:59:26 -0700 |
| commit | e921c3c5b5b8f963f121601d346c50a24bc0cf15 (patch) | |
| tree | a29064762c3b37812596cb82c3e910f7321a85b2 /modules/gallery/models | |
| parent | dbff45cc91ac44f18ef02b8abdd220a2864f050f (diff) | |
| parent | d74aad072d8ccca70efb1c8b673e8368566a1974 (diff) | |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/models')
| -rw-r--r-- | modules/gallery/models/item.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index fc5c3ff9..7ddcb4c2 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -1078,6 +1078,16 @@ class Item_Model_Core extends ORM_MPTT { return $data; } + /** + * Increments the view counter of this item + * 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. + */ + public function increment_view_count() { + db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id") + ->execute(); + } + private function _cache_buster($path) { return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); } |
