vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   SQL query for deleting automatic forum pruning (https://vborg.vbsupport.ru/showthread.php?t=179658)

malmazan 05-18-2008 03:29 PM

SQL query for deleting automatic forum pruning
 
What would the SQL query be for delete all threads older than 90 days from an array of forums?

I want to write a simple php file I can use with the "Scheduled Task" option on the vB adminCP to auto-prune the forums I use for classifieds.

Thanks

Lynne 05-18-2008 03:46 PM

Maybe use an existing hack: Auto Prune Threads
If you don't want to use that one, you can at least download it and see what the query is.

malmazan 05-19-2008 06:19 AM

Quote:

Originally Posted by Lynne (Post 1523694)
Maybe use an existing hack: Auto Prune Threads
If you don't want to use that one, you can at least download it and see what the query is.

I just did that, but there are several queries and I am not savvy enough to be able to re-use them.

malmazan 03-02-2009 08:07 AM

The original code is :

Code:

while ($forum = $vbulletin->db->fetch_array($forums))
{
        $threads = $vbulletin->db->query_read("SELECT threadid, forumid, visible, open, pollid, title FROM " . TABLE_PREFIX . "thread WHERE forumid=$forum[forumid] AND visible IN (0,1,2) AND sticky IN (0,1) AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400)));
          while ($thread = $vbulletin->db->fetch_array($threads))
        {
                    delete_thread($thread['threadid'], false, true, NULL, false, $thread);
          }
          build_forum_counters($forum['forumid']);
}

I would like to manually specify the forums and the number of days. Would this be correct?

Code:

while ($forum = $vbulletin->db->[7,8,9])
{
        $threads = $vbulletin->db->query_read("SELECT threadid, forumid, visible, open, pollid, title FROM " . TABLE_PREFIX . "thread WHERE forumid=$forum[forumid] AND visible IN (0,1,2) AND sticky IN (0,1) AND lastpost <= " . (TIMENOW - (90* 86400)));
          while ($thread = $vbulletin->db->fetch_array($threads))
        {
                    delete_thread($thread['threadid'], false, true, NULL, false, $thread);
          }
          build_forum_counters($forum['forumid']);
}


Lynne 03-02-2009 02:34 PM

No, that is not going to work. You should ask for help in the modification thread. They know the code and are best able to help you.


All times are GMT. The time now is 01:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01000 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete