aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-07-11 12:58:57 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-07-11 12:58:57 +0200
commite68c1fb9e4d5de214c1e483531706ec300ffdb0d (patch)
tree0a1c54e52ca795e317e2c8cb4cdcb28b5a3c2ff8 /phpBB
parent338d29072fd5581968f404576c6faa2dffc4f883 (diff)
downloadforums-e68c1fb9e4d5de214c1e483531706ec300ffdb0d.tar
forums-e68c1fb9e4d5de214c1e483531706ec300ffdb0d.tar.gz
forums-e68c1fb9e4d5de214c1e483531706ec300ffdb0d.tar.bz2
forums-e68c1fb9e4d5de214c1e483531706ec300ffdb0d.tar.xz
forums-e68c1fb9e4d5de214c1e483531706ec300ffdb0d.zip
[ticket/10950] Use database count() and group by instead of doing that in php
PHPBB3-10950
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_privmsgs.php16
1 files changed, 5 insertions, 11 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 6c0adccbed..1d45961ac4 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1143,7 +1143,7 @@ function phpbb_delete_user_pms($user_id)
if (!empty($undelivered_msg))
{
- // A pm is not undelivered, if for any receipt the message was moved
+ // A pm is delivered, if for any receipt the message was moved
// from their NO_BOX to another folder.
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
@@ -1165,23 +1165,17 @@ function phpbb_delete_user_pms($user_id)
$undelivered_user = array();
// Count the messages we delete, so we can correct the user pm data
- $sql = 'SELECT user_id
+ $sql = 'SELECT user_id, COUNT(msg_id) as num_undelivered_privmsgs
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
AND folder_id = ' . PRIVMSGS_NO_BOX . '
- AND ' . $db->sql_in_set('msg_id', $undelivered_msg);
+ AND ' . $db->sql_in_set('msg_id', $undelivered_msg) . '
+ GROUP BY user_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- if (isset($undelivered_user[$row['user_id']]))
- {
- ++$undelivered_user[$row['user_id']];
- }
- else
- {
- $undelivered_user[$row['user_id']] = 1;
- }
+ $undelivered_user[$row['user_id']] = (int) $row['num_undelivered_privmsgs'];
}
$db->sql_freeresult($result);