[ticket/13668] Convert the mcp report_details query to a built query

PHPBB3-13668
This commit is contained in:
brunoais 2015-03-05 16:19:36 +00:00
parent 18de60c0e0
commit fa474c4378

View file

@ -73,14 +73,23 @@ class mcp_reports
// closed reports are accessed by report id // closed reports are accessed by report id
$report_id = request_var('r', 0); $report_id = request_var('r', 0);
$sql_ary = array(
'SELECT' => 'r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour',
$sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour 'FROM' => array(
FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u REPORTS_TABLE => 'r',
WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' REPORTS_REASONS_TABLE => 'rr',
USERS_TABLE => 'u',
),
'WHERE' => '' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . '
AND rr.reason_id = r.reason_id AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id AND r.user_id = u.user_id
AND r.pm_id = 0 AND r.pm_id = 0',
ORDER BY report_closed ASC';
'ORDER_BY' => 'report_closed ASC',
);
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query_limit($sql, 1); $result = $db->sql_query_limit($sql, 1);
$report = $db->sql_fetchrow($result); $report = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);