mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10950] Use database count() and group by instead of doing that in php
PHPBB3-10950
This commit is contained in:
parent
338d29072f
commit
e68c1fb9e4
1 changed files with 5 additions and 11 deletions
|
@ -1143,7 +1143,7 @@ function phpbb_delete_user_pms($user_id)
|
||||||
|
|
||||||
if (!empty($undelivered_msg))
|
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.
|
// from their NO_BOX to another folder.
|
||||||
$sql = 'SELECT msg_id
|
$sql = 'SELECT msg_id
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . '
|
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
|
@ -1165,23 +1165,17 @@ function phpbb_delete_user_pms($user_id)
|
||||||
$undelivered_user = array();
|
$undelivered_user = array();
|
||||||
|
|
||||||
// Count the messages we delete, so we can correct the user pm data
|
// 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 . '
|
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
WHERE author_id = ' . $user_id . '
|
WHERE author_id = ' . $user_id . '
|
||||||
AND folder_id = ' . PRIVMSGS_NO_BOX . '
|
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);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
if (isset($undelivered_user[$row['user_id']]))
|
$undelivered_user[$row['user_id']] = (int) $row['num_undelivered_privmsgs'];
|
||||||
{
|
|
||||||
++$undelivered_user[$row['user_id']];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$undelivered_user[$row['user_id']] = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue