niekas: if interested in removing one SQL call, take a look into $new_topic_data in index.php - I've rewrote my own index now. I also might have made the MOD to work with PostgreSQL and Oracle, I'm not sure though as I only tried to follow the logic already present in the SQL calls... this is what that part looks like:
Code: Select all
//
// Define appropriate SQL
//
switch(SQL_LAYER)
{
case 'postgresql':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, u.user_avatar, u.user_avatar_type, t.topic_id, t.topic_title, t.topic_moved_id
FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t
WHERE p.post_id = f.forum_last_post_id
AND u.user_id = p.poster_id
AND t.topic_last_post_id = f.forum_last_post_id
UNION (
SELECT f.*, NULL, NULL, NULL, NULL
FROM " . FORUMS_TABLE . " f
WHERE NOT EXISTS (
SELECT p.post_time
FROM " . POSTS_TABLE . " p
WHERE p.post_id = f.forum_last_post_id
)
)
ORDER BY cat_id, forum_order";
break;
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, u.user_avatar, u.user_avatar_type, t.topic_id, t.topic_title, t.topic_moved_id
FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t
WHERE p.post_id = f.forum_last_post_id(+)
AND u.user_id = p.poster_id(+)
AND t.topic_last_post_id = f.forum_last_post_id(+)
ORDER BY f.cat_id, f.forum_order";
break;
default:
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, u.user_avatar, u.user_avatar_type, t.topic_id, t.topic_title, t.topic_moved_id
FROM ((( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = f.forum_last_post_id)
GROUP BY f.forum_id ORDER BY f.cat_id, f.forum_order";
break;
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
}
Oh, and to get the avatar... well, you know what is the extra code I use for that