1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Various updates with any luck they fix a few minor issues without causing new ones ...

git-svn-id: file:///svn/phpbb/trunk@2462 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen
2002-04-02 14:04:18 +00:00
parent 374f7adca2
commit 51d9bdeca7
9 changed files with 80 additions and 115 deletions

View File

@@ -90,9 +90,11 @@ function sync($type, $id)
break;
case 'forum':
$sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total
FROM " . POSTS_TABLE . "
WHERE forum_id = $id";
$sql = "SELECT MAX(p.post_id) AS last_post, COUNT(p.post_id) AS total
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
WHERE p.forum_id = $id
AND t.topic_id = p.topic_id
AND t.topic_status <> " . TOPIC_MOVED;
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
@@ -118,21 +120,14 @@ function sync($type, $id)
message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$total_topics = ($row['total']) ? $row['total'] : 0;
}
else
{
$total_topics = 0;
}
$total_topics = ( $row = $db->sql_fetchrow($result) ) ? ( ( $row['total'] ) ? $row['total'] : 0 ) : 0;
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics
WHERE forum_id = $id";
if ( !$result = $db->sql_query($sql) )
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not update forum $id", '', __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
}
break;
@@ -142,7 +137,7 @@ function sync($type, $id)
WHERE topic_id = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not get post ID", '', __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
@@ -150,9 +145,9 @@ function sync($type, $id)
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . "
WHERE topic_id = $id";
if ( !($result = $db->sql_query($sql)) )
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not update topic $id", '', __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
}
}