Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Consulta Mysql para excluir comentários duplicados do Wordpress?


Melhorando a sugestão do Blackbarn, tente isto (depois de fazer backup do 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;
}