Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[已解决] 试发CVC to Discuz的SQL语句

[复制链接]
tangf 发表于 2009-8-24 08:41:03 | 显示全部楼层 |阅读模式
花了一个晚上的时间看了下CVC和Discuz的数据库,写了一些SQL语句,转换过去后Discuz可以跑起来了,但还是有一点问题需要继续修正,暂且先这样吧,所以在这里试发一下。一下是全部的SQL语句:
  1. /*
  2. CVC BBS 1.0 to Discuz的转换
  3. 说明:网上找不到CVC2Discuz的程序,所以我就用SQL语句做了一下。虽然不能完美转换(我认为有很多细节没有处理,也可能存在一定的问题),但至少在帖子、用户、附件内容上完全转换成功。下面的内容就是所有的SQL语句,已经做了简单的注释。
  4. Author:Rover.Tang
  5. Web:http://tangf.cnblogs.com http://sharesh.cn
  6. Mail:tfljh@163.com
  7. 20090824
  8. PS:转换前先将access转成MYSQL,推荐使用Navicat for MySQL,但导入的时候需要注意编码问题。SQL语句的执行也建议使用此工具。
  9. */
  10. --转换category,需要注意fid唯一。
  11. insert into cdb_forums
  12. (fid,type,name)
  13. (SELECT
  14. Id,'group',CategoryName
  15. FROM
  16. bbs_category)

  17. --board,需要注意fid唯一。如果board的id有和category的ID存在相同的情况的话,则无法完全导入,建议将转换成功后的category的ID的fid改掉。
  18. insert into cdb_forums
  19. (fid,type,name)
  20. (SELECT
  21. Id,'group',CategoryName
  22. FROM
  23. bbs_category)

  24. --显示board和category,也可以在上面的那个语句中就处理掉
  25. update cdb_forums
  26. set status=1

  27. --显示board的描述信息
  28. insert cdb_forumfields
  29. (fid,description)
  30. (select id,description from bbs_board)

  31. --导入用户。需要注意,uid不要重复和存在
  32. insert cdb_members
  33. (uid,username,password,email)
  34. (select uid,username,password,email from bbs_member)

  35. --导入用户信息,只导入签名,其余的都抛弃掉,是由于cvc的用户信息用了xml而不是数据库。
  36. insert into cdb_memberfields
  37. (uid,sightml)
  38. (select uid,signature from bbs_member)

  39. --导入用户到UC,两边需要同步,不然无法登陆
  40. insert uc_members
  41. (uid,username,password,email)
  42. (select uid,username,password,email from bbs_member)

  43. --导入用户信息到UC,其实只是建立uid与member对应
  44. insert uc_memberfields
  45. (uid)
  46. (select uid from bbs_member)

  47. --导入附件
  48. insert into cdb_attachments
  49. (aid,tid,pid,filename,filesize,attachment,downloads,isimage,uid)
  50. (select id,topicid,replyid,attachname,attachsize,attachpath,downloads,attachtype,uid from bbs_attach)

  51. --更新字段是否为图片。不是图片的DZ使用0,而CVC使用2所以将其更改为0
  52. update cdb_attachments
  53. set isimage=0
  54. where isimage<>1
  55. --更新字段description。这个字段其实更新的并不是很好,description更改为名称其实就可以了。
  56. update cdb_attachments
  57. set description=right(attachment,length(attachment)-instr(attachment,'.'))
  58. where instr(attachment,'.')<>0
  59. --更新字段filetype,bmp:image/bmp;
  60. update cdb_attachments
  61. set filetype='image/bmp'
  62. where description='bmp'

  63. update cdb_attachments
  64. set filetype='application/msword'
  65. where description='doc'

  66. update cdb_attachments
  67. set filetype='image/gif'
  68. where description='gif'

  69. update cdb_attachments
  70. set filetype='image/pjpeg'
  71. where description='jpg'

  72. update cdb_attachments
  73. set filetype='image/x-png'
  74. where description='png'

  75. update cdb_attachments
  76. set filetype='application/msword'
  77. where description='doc'

  78. update cdb_attachments
  79. set filetype='application/octet-stream'
  80. where description='rar'


  81. --更新主题
  82. insert into cdb_threads
  83. (tid,fid,author,authorid,subject,lastposter,views,replies)
  84. (select id,boardid,authorname,authorid,title,lastreplyauthor,views,replies from bbs_topic)

  85. --更新帖子
  86. insert into cdb_posts
  87. (pid,tid,author,authorid,message)
  88. (select id,topicid,authorname,authorid,body from bbs_reply)

  89. --更新posts表,将主题也放入其中
  90. insert cdb_posts
  91. (fid,tid,first,author,authorid,subject,message)
  92. (select boardid,id,1,authorname,authorid,title,body from bbs_topic)

  93. --更新posts表中的fid,就是将post的board的ID和topic的board的ID对应起来
  94. update cdb_posts,bbs_topic
  95. set cdb_posts.fid=bbs_topic.boardid
  96. where (cdb_posts.tid=bbs_topic.id) and (cdb_posts.fid=0)

  97. update cdb_posts
  98. set usesig=1

  99. update cdb_threads
  100. set supe_pushstatus=1
  101. --完成了这些以后,就可以登录后台在工具中更新缓存,更新帖子数等等,需要操作这些内容后才能看到论坛版块中的帖子,不然是看不到帖子的。

  102. --更新管理组
  103. update cdb_members,bbs_administrator
  104. set cdb_members.adminid=1
  105. where cdb_members.uid=bbs_administrator.uid

  106. update cdb_members,bbs_administrator
  107. set cdb_members.groupid=1
  108. where cdb_members.uid=bbs_administrator.uid
  109. --更新超级版主
  110. update cdb_members,bbs_manager
  111. set cdb_members.adminid=2
  112. where cdb_members.uid=bbs_manager.uid

  113. update cdb_members,bbs_manager
  114. set cdb_members.groupid=2
  115. where cdb_members.uid=bbs_manager.uid
  116. --更新版主
  117. update cdb_members,bbs_Moderator
  118. set cdb_members.adminid=3
  119. where cdb_members.uid=bbs_Moderator.uid

  120. update cdb_members,bbs_Moderator
  121. set cdb_members.groupid=3
  122. where cdb_members.uid=bbs_Moderator.uid

  123. insert into cdb_moderators
  124. (uid,fid)
  125. (select uid,boardid from bbs_Moderator)
  126. --更新完版主后需要在后台处理一下板块里的版主

  127. --更新其他用户组,这里简单处理成了新手上路。需要更新复杂一些的话,找出组的对应关系即可。
  128. update cdb_members
  129. set cdb_members.groupid=10
  130. where cdb_members.groupid=0

  131. --允许discuzcode,也就是CVC的ubbcode
  132. update cdb_forums
  133. set allowbbcode=1
  134. --允许笑脸图标
  135. update cdb_forums
  136. set allowsmilies=1
  137. --允许HTML
  138. update cdb_forums
  139. set allowhtml=1


  140. --更新附件,更新完成后附件自动在帖子中间。原有的附件代码就完全没用了。下面就是更新帖子内容中的附件了,更新需要分为两个部分,1是更新帖子中的图片标签内容,2是删除帖子中除了图片以外的标签内容
  141. update cdb_posts,bbs_reply
  142. set cdb_posts.attachment=1
  143. where cdb_posts.pid=bbs_reply.id and bbs_reply.attachids<>'' and bbs_reply.attachids<>'-1'

  144. /*
  145. TODO:
  146. 1,如上,更新帖子中的图片标签,删除图片以外的标签,此点来看需要写一个程序了。
  147. 2,用户的帖子还不在用户的管理面板中,需要做继续的检查。
  148. 3,。。。
  149. */
复制代码
回复

使用道具 举报

 楼主| tangf 发表于 2009-8-24 08:41:16 | 显示全部楼层
写的有点乱,就将就着看吧。
顺便说一下,由于密码的加密两者是不一致的,所以所有用户的密码都需要自己找回一次。
看来问题还蛮多。。。
回复

使用道具 举报

huihui0103 发表于 2009-8-24 09:19:12 | 显示全部楼层
写的有点乱,就将就着看吧。
顺便说一下,由于密码的加密两者是不一致的,所以所有用户的密码都需要自己找回一次。
看来问题还蛮多。。。
tangf 发表于 2009-8-24 08:41

谢谢分享。不过最好还是写成转换程序 程序中处理一些逻辑问题要好很多
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-16 06:13 , Processed in 0.082116 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表