2012-02-13 33 views
0

我的WordPress的网站最近被黑了,所以我不得不重新安装一切。 WordPress的resinstalled,数据库备份导入,一切都很好,很棒。然后,我安装了Disqus插件并同步(Disqus之前曾在网站被黑客使用过)。大不 - 不是。现在我的网站上有每一条评论的副本!更糟糕的是,重复的评论已被同步回到Disqus!需要一个MySQL查询来删除Wordpress的评论

所以,我知道这是一个PHPMyAdmin中的简单查询,但我不知道它!请帮忙!

回答

0

提供在MySQL中删除查询

Delete from (tablename) where (primarykey) 

但我认为WordPress的有它的数据库查询构建选择删除和​​更新。

这里还有一个,如果你使用的插件Disqus

If you're logged into your Disqus account you can also choose to delete a comment at your dashboard. This will remove it from your profile and remove all identifying information from the comment on the original page. Once a comment has been anonymized it cannot be claimed again.

0

请记住,有a WordPress Stack Exchange website;)

,除非你知道WPDB名字从你的头顶,我会用PHP。一定要先备份数据库!像这样:

global $wpdb; 

$comments = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."_comments" 
    ." ORDER BY comment_post_ID, comment_content"); 

$prev = NULL; 

foreach($comments as $comment) { 

    if ($prev && $prev->comment_content == $comment->comment_content 
    && $prev->comment_post_ID == $comment->comment_post_ID) { // add maybe other rules here 

    $wpdb->query("DELETE FROM ".$wpdb->prefix."_comments" WHERE comment_ID == $comment- >comment_ID"); 

    } 
    else 
    $prev = $comment; 
} 
+0

@digitaltoday嗨,也许我很困惑,但我试着运行这个,我得到了一个错误'解析错误:语法错误,意想不到的T_STRING在第8行/home/electroj/public_html/comment.php' – skarz 2012-02-13 20:50:45

+0

我更新代码(仍未测试),现在就试试 – Dan 2012-02-13 22:50:22

0

如果他不知道如何使用mysql,我认为重新编辑wp接口非常棒,因为通常wp会为查询创建函数。它可能会再次导致其遭到破坏。

它不工作的唯一原因可能是因为它们使用了插件。我想是这样。!