aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop
diff options
context:
space:
mode:
authorBart van Bragt <bartvb@users.sourceforge.net>2001-11-24 17:17:32 +0000
committerBart van Bragt <bartvb@users.sourceforge.net>2001-11-24 17:17:32 +0000
commit7eee52fff321c1ba06bf321209cd2beb211fd6b3 (patch)
treeddaeaa00702130e8d581c8992499ac2e261a5f2a /phpBB/develop
parent92e5512011789d1ecab92a6f3e8fc4a70e0e4a00 (diff)
downloadforums-7eee52fff321c1ba06bf321209cd2beb211fd6b3.tar
forums-7eee52fff321c1ba06bf321209cd2beb211fd6b3.tar.gz
forums-7eee52fff321c1ba06bf321209cd2beb211fd6b3.tar.bz2
forums-7eee52fff321c1ba06bf321209cd2beb211fd6b3.tar.xz
forums-7eee52fff321c1ba06bf321209cd2beb211fd6b3.zip
Finally moved the bbcode_uid from posts to posts_text, DON'T FORGET TO RUN THE CONVERT SCRIPT IN /develop/ !!
git-svn-id: file:///svn/phpbb/trunk@1436 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/develop')
-rw-r--r--phpBB/develop/convert_bbcodeuid.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/phpBB/develop/convert_bbcodeuid.php b/phpBB/develop/convert_bbcodeuid.php
new file mode 100644
index 0000000000..9e2f959046
--- /dev/null
+++ b/phpBB/develop/convert_bbcodeuid.php
@@ -0,0 +1,82 @@
+<?php
+
+$phpbb_root_path = "../";
+
+include($phpbb_root_path . 'extension.inc');
+include($phpbb_root_path . 'config.'.$phpEx);
+include($phpbb_root_path . 'includes/constants.'.$phpEx);
+include($phpbb_root_path . 'includes/db.'.$phpEx);
+
+function query($sql, $errormsg)
+{
+ global $db;
+ if(!$result = $db->sql_query($sql))
+ {
+ print "<br><font color=\"red\">\n";
+ print "$errormsg<br>";
+ $sql_error = $db->sql_error();
+ print $sql_error['code'] .": ". $sql_error['message']. "<br>\n";
+ print "<pre>$sql</pre>";
+ print "</font>\n";
+ return FALSE;
+ }
+ else
+ {
+ return $result;
+ }
+}
+
+if($HTTP_GET_VARS['delete'] == 'true')
+{
+ $sql = "ALTER TABLE ".POSTS_TABLE."
+ DROP bbcode_uid";
+ query($sql, "Didn't manage to drop the bbcode_uid table in ".POSTS_TABLE);
+ print "All done now. Deleted the bbcode_uid column from the posts table.<p>";
+ exit;
+}
+
+
+$sql = "ALTER TABLE ".POSTS_TEXT_TABLE."
+ ADD bbcode_uid char(10) NOT NULL";
+print "Adding bbcode_uid field to ".POSTS_TEXT_TABLE.".<br>\n";
+$result = query($sql, "Couldn't get add bbcode_uid field to ".POSTS_TEXT_TABLE.".");
+
+$sql = "
+ SELECT
+ count(*) as total,
+ max(post_id) as maxid
+ FROM ". POSTS_TABLE;
+$result = query($sql, "Couldn't get max post_id.");
+$maxid = $db->sql_fetchrow($result);
+$totalposts = $maxid['total'];
+$maxid = $maxid['maxid'];
+
+$batchsize = 200;
+print "Going to convert BBcode in posts with $batchsize messages at a time and $totalposts in total.<br>\n";
+for($i = 0; $i <= $maxid; $i += $batchsize)
+{
+ $batchstart = $i + 1;
+ $batchend = $i + $batchsize;
+
+ print "Moving BBcode UID in post number $batchstart to $batchend<br>\n";
+ flush();
+ $sql = "
+ SELECT
+ post_id,
+ bbcode_uid
+ FROM "
+ .POSTS_TABLE."
+ WHERE
+ post_id BETWEEN $batchstart AND $batchend";
+ $result = query($sql, "Couldn't get ". POSTS_TABLE .".post_id $batchstart to $batchend");
+ while($row = mysql_fetch_array($result))
+ {
+ query("UPDATE ".POSTS_TEXT_TABLE." set bbcode_uid = '". $row['bbcode_uid']. "' WHERE post_id = ".$row['post_id'], "Was unable to update the posts text table with the BBcode_uid");
+ }
+}
+
+echo "Click <a href=\"$PHP_SELF?delete=true\">HERE</a> to remove the bbcode_uid table from the POSTS table (if you didn't get any serious error messages).<p>";
+
+$db->sql_close();
+
+?>