解决 Discuz!X3.x “抱歉,该附件无法读取”的问题

报错信息:
抱歉,该附件无法读取
经排查,权限之类的完全正确,不要用哪些权限问题来糊弄人。
主要是这个表:pre_forum_attachment,丢掉了pre_forum_attachment_(0-9)中的附件数据 (aid,tid,pid, uid,tableid,downloads)。
解决办法:sql执行以下命令(有一个缺点,附件下载次数没有了。我这里模拟的是10次)。如果想完全的恢复,只能恢复备份数据重新执行。当然,我这边客户已经把备份数据手贱删除了。
再次郑重说明,删除数据一定要谨慎,数据无价,谨慎操作。

INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,1,'10' FROM pre_forum_attachment_0 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,1,'10' FROM pre_forum_attachment_1 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,2,'10' FROM pre_forum_attachment_2 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,3,'10' FROM pre_forum_attachment_3 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,4,'10' FROM pre_forum_attachment_4 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,5,'10' FROM pre_forum_attachment_5 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,6,'10' FROM pre_forum_attachment_6 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,7,'10' FROM pre_forum_attachment_7 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,8,'10' FROM pre_forum_attachment_8 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);
INSERT INTO pre_forum_attachment(aid,tid,pid, uid,tableid,downloads)SELECT aid,tid,pid, uid,9,'10' FROM pre_forum_attachment_9 d WHERE NOT EXISTS (select tid from pre_forum_attachment where pre_forum_attachment.aid = d.aid);

本文链接:

https://dev.euyyue.com/note/354.html
1 + 2 =
快来做第一个评论的人吧~