Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELETE FROM comment
- WHERE nid = <the involved node id>
- SELECT * FROM comment
- WHERE nid = <the involved node id>
- DELETE FROM field_data_comment_body
- WHERE entity_type = "comment"
- AND entity_id IN (
- SELECT cid
- FROM comment
- WHERE nid = <the involved node id>
- )
- <?php
- // Change this to the nid you want to clear comments from
- $nid = 12345;
- // Queries the database for all comment IDs associated with the nid, max 1000
- $cids = db_select('comment', 'c')
- ->fields('c', array('cid'))
- ->condition('c.nid', $nid)
- ->range(0, 1000)
- ->execute()
- ->fetchCol();
- if (!count($cids)) {
- drush_print("No more comments found. Aborting.");
- // Abort with an error code (so a bash script can key off that)
- exit(1);
- }
- // Delete the comments with comment IDs we got from the DB
- comment_delete_multiple($cids);
- drush_print(count($cids) . " comments deleted");
- #!/bin/bash
- while drush @your-server-alias scr /path/to/script/on/server/so.php; do
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement