本帖最后由 evenzhou 于 2011-5-19 13:04 编辑
出问题的用户:新安装的x2beta 版然后升级到x2RC
问题出在 x2RC版的升级程序中没有考虑 x2beta的中附件,所以用户在升级的时候应该跳过附件的升级,然后单独导入附件数据,x2 RC_ gbk升级版程序:
主要更改:去掉了附件的升级
- elseif($_GET['op'] == 'forumattach') {
- $nextop = 'moderate';
- $limit = 10000;
- $start = !empty($_GET['start']) ? $_GET['start'] : 0;
- $needupgrade = DB::query("SELECT COUNT(*) FROM ".DB::table('forum_attachmentfield'), 'SILENT');
- $count = DB::result_first("SELECT COUNT(*) FROM ".DB::table('forum_attachment'));
- if($needupgrade && $count) {
- if(!$start) {
- for($i = 0;$i < 10;$i++) {
- DB::query("TRUNCATE ".DB::table('forum_attachment_'.$i));
- }
- }
- $query = DB::query("SELECT a.*,af.description FROM ".DB::table('forum_attachment')." a
- LEFT JOIN ".DB::table('forum_attachmentfield')." af USING(aid)
- ORDER BY aid LIMIT $start, $limit");
- if(DB::num_rows($query)) {
- while($row = DB::fetch($query)) {
- $row = daddslashes($row);
- $tid = (string)$row['tid'];
- $tableid = $tid{strlen($tid)-1};
- DB::update('forum_attachment', array('tableid' => $tableid), array('aid' => $row['aid']));
- DB::insert('forum_attachment_'.$tableid, array(
- 'aid' => $row['aid'],
- 'tid' => $row['tid'],
- 'pid' => $row['pid'],
- 'uid' => $row['uid'],
- 'dateline' => $row['dateline'],
- 'filename' => $row['filename'],
- 'filesize' => $row['filesize'],
- 'attachment' => $row['attachment'],
- 'remote' => $row['remote'],
- 'description' => $row['description'],
- 'readperm' => $row['readperm'],
- 'price' => $row['price'],
- 'isimage' => $row['isimage'],
- 'width' => $row['width'],
- 'thumb' => $row['thumb'],
- 'picid' => $row['picid'],
- ));
- }
- $start += $limit;
- show_msg("论坛附件表升级中 ... $start/$count", "$theurl?step=data&op=forumattach&start=$start");
- }
- DB::query("DROP TABLE `".DB::table('forum_attachmentfield')."`");
- DB::query("ALTER TABLE ".DB::table('forum_attachment')."
- DROP `width`,
- DROP `dateline`,
- DROP `readperm`,
- DROP `price`,
- DROP `filename`,
- DROP `filetype`,
- DROP `filesize`,
- DROP `attachment`,
- DROP `isimage`,
- DROP `thumb`,
- DROP `remote`,
- DROP `picid`
- ");
- }
- show_msg("论坛附件表升级完毕", "$theurl?step=data&op=$nextop");
- }
复制代码
由于附件表中filename 字段值为空,导致程序没法识别出文件的扩展名,不能与程序定义的文件类型图标匹配 如果attachement为空,就不能下载文件,filesize存的是附件的大小
导入x2 beta附件的方法:
首先,确保以前有备份(x2 beta备份的完整数据)
然后 登录phpmyadmin( 数据库管理员软件),查看附件中filename 和 attachement 字段值是否为空,
如图:
如果为空
清空掉 附件表 pre_forum_attachment 至 pre_forum_attachment_unused 共 12个表 中的记录( 注意:自己确保已经备份好数据)
找到备份数据,从其中分离出 关于 附件表的insert into 语句 (有12个表的insert语句)
如这样的语句:
- INSERT INTO pre_forum_attachment VALUES ('1','3','3','1','3','0');
- INSERT INTO pre_forum_attachment VALUES ('2','3','3','1','3','0');
- INSERT INTO pre_forum_attachment VALUES ('3','3','4','1','3','0');
- INSERT INTO pre_forum_attachment_3 VALUES ('2','3','3','1','1305076324',0x3030312e6a7067,'584614',0x3230313130352f31312f3039313230357a6b76716e3773786e6a6a386b3734372e6a7067,'0','','0','0','-1','1680','0','0');
- INSERT INTO pre_forum_attachment_3 VALUES ('1','3','3','1','1305076297',0x323031312d352d31302e646f6378,'14265',0x3230313130352f31312f3039313133373137317866747766327077366c3278372e617474616368,'0','','0','0','0','0','0','0');
- INSERT INTO pre_forum_attachment_3 VALUES ('3','3','4','1','1305076442',0x617069b5c4baacd2e52e747874,'10922',0x3230313130352f31312f3039313430336a613665346a367365383738347232362e747874,'0','','0','0','0','0','0','0');
复制代码
将语句保存sql文件
接着用phpmyadmin 插入 数据库 或 将文件保存为sql文件 直接 import (注意:编码要统一)
如图:
|