No announcement yet.

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

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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...
    Bimmerforums - The Ultimate BMW Forum

  • #2
    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.
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography

    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    • #3
      What I could think of is making a
      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)
      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.
      ::[ Skill-Club's Forum ]::


      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.