mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10605] Split query to be able to use indexes
PHPBB3-10605
This commit is contained in:
parent
9c8aab4d32
commit
0397b46217
1 changed files with 31 additions and 3 deletions
|
@ -1098,11 +1098,11 @@ function phpbb_delete_user_pms($user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get PM Information for later deleting
|
// Get PM Information for later deleting
|
||||||
|
// The two queries where split, so we can use our indexes
|
||||||
|
// Part 1: get PMs the user received
|
||||||
$sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
|
$sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
|
||||||
FROM ' . PRIVMSGS_TO_TABLE . '
|
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
WHERE user_id = ' . $user_id . '
|
WHERE user_id = ' . $user_id;
|
||||||
OR (author_id = ' . $user_id . '
|
|
||||||
AND folder_id = ' . PRIVMSGS_NO_BOX . ')';
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
$undelivered_msg = $undelivered_user = $delete_ids = array();
|
$undelivered_msg = $undelivered_user = $delete_ids = array();
|
||||||
|
@ -1127,6 +1127,34 @@ function phpbb_delete_user_pms($user_id)
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Part 2: get PMs the user sent
|
||||||
|
$sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
|
||||||
|
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
|
WHERE author_id = ' . $user_id . '
|
||||||
|
AND folder_id = ' . PRIVMSGS_NO_BOX;
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if ($row['author_id'] == $user_id && $row['folder_id'] == PRIVMSGS_NO_BOX)
|
||||||
|
{
|
||||||
|
// Undelivered messages
|
||||||
|
$undelivered_msg[] = $row['msg_id'];
|
||||||
|
|
||||||
|
if (isset($undelivered_user[$row['user_id']]))
|
||||||
|
{
|
||||||
|
++$undelivered_user[$row['user_id']];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$undelivered_user[$row['user_id']] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$delete_ids[(int) $row['msg_id']] = (int) $row['msg_id'];
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (empty($delete_ids))
|
if (empty($delete_ids))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue