Drupal コメントを SQL で一括削除
Nid: 1220
status が hidden のコメントを削除する例。0 = hidden, 1 = closed, 2 = open
データを確認、コメントの本体を消して、
$ drush sql-query "SELECT * FROM comment WHERE status = 0" $ drush sql-query "DELETE FROM comment WHERE status = 0"
リンク先の無くなったデータを削除。
$ drush sql-query " DELETE field_data_comment_body FROM field_data_comment_body LEFT JOIN comment ON field_data_comment_body.entity_id = comment.cid WHERE comment.cid IS NULL;" $ drush sql-query " DELETE field_revision_comment_body FROM field_revision_comment_body LEFT JOIN comment ON field_revision_comment_body.entity_id = comment.cid WHERE comment.cid IS NULL;"
関連記事
- 1 of 2
- next ›