mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
use only one query for updating download counts.
git-svn-id: file:///svn/phpbb/trunk@3886 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
5e1a81ad66
commit
92141c3e35
1 changed files with 9 additions and 12 deletions
|
@ -501,7 +501,7 @@ if (!empty($poll_start))
|
||||||
|
|
||||||
|
|
||||||
// Container for user details, only process once
|
// 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;
|
$has_attachments = FALSE;
|
||||||
$force_encoding = '';
|
$force_encoding = '';
|
||||||
$bbcode_bitfield = 0;
|
$bbcode_bitfield = 0;
|
||||||
|
@ -1022,8 +1022,6 @@ foreach ($rowset as $key => $row)
|
||||||
// Process Attachments for this post
|
// Process Attachments for this post
|
||||||
if (sizeof($attachments[$row['post_id']]))
|
if (sizeof($attachments[$row['post_id']]))
|
||||||
{
|
{
|
||||||
$update_count = array();
|
|
||||||
|
|
||||||
foreach ($attachments[$row['post_id']] as $attachment)
|
foreach ($attachments[$row['post_id']] as $attachment)
|
||||||
{
|
{
|
||||||
// Some basics...
|
// 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]);
|
unset($rowset[$key]);
|
||||||
|
@ -1254,6 +1243,14 @@ unset($user_cache);
|
||||||
// Mark topics read
|
// Mark topics read
|
||||||
markread('topic', $forum_id, $topic_id, $topic_data['topic_last_post_id']);
|
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
|
// Update the topic view counter, excepted when the user was already reading it
|
||||||
if (!preg_match("#&t=$topic_id#", $user->data['session_page']))
|
if (!preg_match("#&t=$topic_id#", $user->data['session_page']))
|
||||||
|
|
Loading…
Add table
Reference in a new issue