mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
go with Ashe's suggestion...
git-svn-id: file:///svn/phpbb/trunk@4676 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
6016228752
commit
3cb634c796
1 changed files with 17 additions and 36 deletions
|
@ -137,44 +137,25 @@ function update_last_post_information($type, $id)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
switch ($type)
|
|
||||||
{
|
|
||||||
case 'forum':
|
|
||||||
// Splitted query - performance gain
|
|
||||||
$sql = 'SELECT MAX(post_time) AS max_post_time FROM ' . POSTS_TABLE . '
|
|
||||||
WHERE post_approved = 1
|
|
||||||
AND forum_id = ' . $id;
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
$row = $db->sql_fetchrow($result);
|
|
||||||
|
|
||||||
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
|
||||||
WHERE p.poster_id = u.user_id
|
|
||||||
AND p.post_time = ' . $row['max_post_time'];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'topic':
|
|
||||||
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
|
||||||
WHERE p.post_approved = 1
|
|
||||||
AND p.poster_id = u.user_id
|
|
||||||
AND p.topic_id = $id
|
|
||||||
ORDER BY p.post_time DESC";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
|
|
||||||
$row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$update_sql = array();
|
$update_sql = array();
|
||||||
|
|
||||||
if ($row)
|
$sql = 'SELECT MAX(post_id) as last_post_id
|
||||||
|
FROM ' . POSTS_TABLE . "
|
||||||
|
WHERE post_approved = 1
|
||||||
|
AND {$type}_id = $id";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
|
||||||
|
if (!empty($row['last_post_id']))
|
||||||
{
|
{
|
||||||
|
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
|
||||||
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||||
|
WHERE p.poster_id = u.user_id
|
||||||
|
AND p.post_id = ' . $row['last_post_id'];
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$update_sql[] = $type . '_last_post_id = ' . (int) $row['post_id'];
|
$update_sql[] = $type . '_last_post_id = ' . (int) $row['post_id'];
|
||||||
$update_sql[] = $type . '_last_post_time = ' . (int) $row['post_time'];
|
$update_sql[] = $type . '_last_post_time = ' . (int) $row['post_time'];
|
||||||
$update_sql[] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
|
$update_sql[] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
|
||||||
|
@ -187,7 +168,7 @@ function update_last_post_information($type, $id)
|
||||||
$update_sql[] = 'forum_last_poster_id = 0';
|
$update_sql[] = 'forum_last_poster_id = 0';
|
||||||
$update_sql[] = "forum_last_poster_name = ''";
|
$update_sql[] = "forum_last_poster_name = ''";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $update_sql;
|
return $update_sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue