aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2003-04-18 15:04:12 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2003-04-18 15:04:12 +0000
commit92141c3e356f38c25830239a1449b5013e8b9a4c (patch)
tree161e832a923d17637ec2c5a2e645de47034e1841
parent5e1a81ad66bd37f1ea2ee6d936cb0650c9424d53 (diff)
downloadforums-92141c3e356f38c25830239a1449b5013e8b9a4c.tar
forums-92141c3e356f38c25830239a1449b5013e8b9a4c.tar.gz
forums-92141c3e356f38c25830239a1449b5013e8b9a4c.tar.bz2
forums-92141c3e356f38c25830239a1449b5013e8b9a4c.tar.xz
forums-92141c3e356f38c25830239a1449b5013e8b9a4c.zip
use only one query for updating download counts.
git-svn-id: file:///svn/phpbb/trunk@3886 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/viewtopic.php21
1 files changed, 9 insertions, 12 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index b51d8b9cb9..d4af16bc45 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -501,7 +501,7 @@ if (!empty($poll_start))
// Container for user details, only process once
-$user_cache = $attachments = $attach_list = $rowset = array();
+$user_cache = $attachments = $attach_list = $rowset = $update_count = array();
$has_attachments = FALSE;
$force_encoding = '';
$bbcode_bitfield = 0;
@@ -1022,8 +1022,6 @@ foreach ($rowset as $key => $row)
// Process Attachments for this post
if (sizeof($attachments[$row['post_id']]))
{
- $update_count = array();
-
foreach ($attachments[$row['post_id']] as $attachment)
{
// Some basics...
@@ -1233,15 +1231,6 @@ foreach ($rowset as $key => $row)
}
}
}
-
- // Update download count
- if (count($update_count))
- {
- $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "
- SET download_count = download_count + 1
- WHERE attach_id IN (" . implode(', ', array_unique($update_count)) . ")";
- $db->sql_query($sql);
- }
}
unset($rowset[$key]);
@@ -1254,6 +1243,14 @@ unset($user_cache);
// Mark topics read
markread('topic', $forum_id, $topic_id, $topic_data['topic_last_post_id']);
+// Udate the attachment download counts
+if (count($update_count))
+{
+ $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "
+ SET download_count = download_count + 1
+ WHERE attach_id IN (" . implode(', ', array_unique($update_count)) . ")";
+ $db->sql_query($sql);
+}
// Update the topic view counter, excepted when the user was already reading it
if (!preg_match("#&t=$topic_id#", $user->data['session_page']))