Announcement

Collapse
No announcement yet.

Is it possible to delete all attachments for a particular thread?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hellcat
    replied
    What I could think of is making a
    Code:
    SELECT attachmentid FROM post WHERE threadid = '$threadID'
    ($threadID will be the ID of the thread you want to prune the attachments from - obviosly )

    Then make a loop that executes the following SQL query for any attachmentid not "0":
    (the current id would be stored in $attachmentID in this example)
    Code:
    DELETE FROM attachment WHERE attachmentid = '$attachmentID'
    But I have no idea of how long this query would take on large (or huge ) databases and loooong threads with many attachments.
    Last edited by Hellcat; Wed 30 Jul '03, 1:12pm.

    Leave a comment:


  • Steve Machol
    replied
    There is no built-in function to do this. You can probably do it with a MySQL query but I don't know what that query would be. Perhaps someone else will know.

    Leave a comment:


  • Is it possible to delete all attachments for a particular thread?

    I've seen quite a few threads that tell you how to delete all attachments, or delete all attachments older than X date.

    However, I haven't seen any threads that tell you how to delete all attachments over a particular size or how to delete attachments associated with a particular thread (like one of those post pictures of yourself threads ... with 200+ attachments in one thread ).

    Anybody have any ideas? Oh... and the attachments table is about 2.2GB, so I'm hoping it'll be a quick piece of code so it doesn't lock that table while it's executing...
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X