Mysql
 sql >> Database >  >> RDS >> Mysql

Query Mysql per eliminare i commenti Wordpress duplicati?

Migliorando su suggerimento di Blackbarn, prova questo (dopo aver eseguito il backup del db):

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;
}