diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-08-07 01:12:19 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-08-07 01:12:19 +0200 |
commit | 940b9e0658348be7c66b7f5375f086f2d370abb2 (patch) | |
tree | 6b629079ab83dda4b8c81503897b8faadd274a0a /phpBB | |
parent | 56cd7e54756b743e1e2f7587fe574c1a2c395add (diff) | |
download | forums-940b9e0658348be7c66b7f5375f086f2d370abb2.tar forums-940b9e0658348be7c66b7f5375f086f2d370abb2.tar.gz forums-940b9e0658348be7c66b7f5375f086f2d370abb2.tar.bz2 forums-940b9e0658348be7c66b7f5375f086f2d370abb2.tar.xz forums-940b9e0658348be7c66b7f5375f086f2d370abb2.zip |
[feature/attach-dl] Combine download_id and post_id queries.
PHPBB3-11042
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/download/file.php | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php index e50c4e18b2..0978f93402 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -153,21 +153,11 @@ if (!$config['allow_attachments'] && !$config['allow_pm_attach']) // If multiple arguments are provided, the precedence is as follows: // $download_id, $post_id, $topic_id -if ($download_id) +if ($download_id || $post_id) { $sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime - FROM ' . ATTACHMENTS_TABLE . " a - WHERE a.attach_id = $download_id"; - $result = $db->sql_query($sql); - $attachments = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); -} -else if ($post_id) -{ - $sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime - FROM ' . ATTACHMENTS_TABLE . " a - WHERE a.post_msg_id = $post_id"; - + FROM ' . ATTACHMENTS_TABLE . ' a + WHERE ' . ($download_id ? "a.attach_id = $download_id" : "a.post_msg_id = $post_id"); $result = $db->sql_query($sql); $attachments = $db->sql_fetchrowset($result); $db->sql_freeresult($result); @@ -179,7 +169,6 @@ else if ($topic_id) WHERE p.topic_id = $topic_id AND p.post_attachment = 1 AND a.post_msg_id = p.post_id"; - $result = $db->sql_query($sql); $attachments = $db->sql_fetchrowset($result); $db->sql_freeresult($result); |