From 26190e5c3bdc9344ae635e7f5be52f9207201fa9 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 17 Aug 2002 22:08:34 +0000 Subject: Some sql changes git-svn-id: file:///svn/phpbb/trunk@2866 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/update_script.php | 81 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) (limited to 'phpBB/install/update_script.php') diff --git a/phpBB/install/update_script.php b/phpBB/install/update_script.php index 3d62122dac..4ed33a249f 100644 --- a/phpBB/install/update_script.php +++ b/phpBB/install/update_script.php @@ -1,6 +1,6 @@ post checksums'); + + $sql_ary[] = "UPDATE " . $table_prefix . "posts_text + SET post_checksum = MD5(post_text)"; + + foreach ( $sql_ary as $sql ) + { + $db->sql_query($sql); + } + + gen_str_ok(); + gen_str_init('* Updating forum post info'); + + switch ( SQL_LAYER ) + { + case 'oracle': + $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id + FROM " . $table_prefix . "forums f, " . $table_prefix . "posts p, " . $table_prefix . "users u + WHERE p.post_id = f.forum_last_post_id(+) + AND u.user_id = p.poster_id(+)"; + break; + + default: + $sql = "SELECT f.forum_id, p.post_time, p.post_username, u.username, u.user_id + FROM (( " . $table_prefix . "forums f + LEFT JOIN " . $table_prefix . "posts p ON p.post_id = f.forum_last_post_id ) + LEFT JOIN " . $table_prefix . "users u ON u.user_id = p.poster_id )"; + break; + } + $result = $db->sql_query($sql); + + $sql_ary = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $forum_id = $row['forum_id']; + + $sql_ary[] = "UPDATE " . $table_prefix . "forums + SET forum_last_poster_id = " . $row['user_id'] . ", forum_last_poster_name = '" . $row['post_username'] . "', forum_last_post_time = " . $row['post_time'] . " + WHERE forum_id = $forum_id"; + + $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time + FROM " . $table_prefix . "topics t, " . $table_prefix . "users u, " . $table_prefix . "posts p, " . $table_prefix . "posts p2, " . $table_prefix . "users u2 + WHERE t.forum_id = $forum_id + AND u.user_id = t.topic_poster + AND p.post_id = t.topic_first_post_id + AND p2.post_id = t.topic_last_post_id + AND u2.user_id = p2.poster_id"; + $result2 = $db->sql_query($sql); + + while ( $row2 = $db->sql_fetchrow($result2) ) + { + $sql_ary[] = "UPDATE " . $table_prefix . "topics + SET topic_first_poster_name = '" . $row2['post_username'] . "', topic_last_poster_id = " . $row2['id2'] . ", topic_last_post_time = " . $row2['post_time'] . ", topic_last_poster_name = '" . $row2['post_username2'] . "' + WHERE topic_id = " . $row2['topic_id']; + } + $db->sql_freeresult($result2); + + unset($row2); + } + $db->sql_freeresult($result); + + foreach ( $sql_ary as $sql ) + { + $db->sql_query($sql); + } + + gen_str_ok(); + break; default; print "* No updates needed
\n"; } - $sql = "UPDATE " . $table_prefix . "config SET config_value = '$version' WHERE config_name = 'version'"; -- cgit v1.2.1