vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Query to close threads with a prefix? (https://vborg.vbsupport.ru/showthread.php?t=324123)

kgroneman 01-04-2017 08:06 PM

Query to close threads with a prefix?
 
I'd like to use an SQL query to close all threads in a specific forum that have a specific prefix (prefix=product version). I don't know how to create queries. The best I can come up with is this:

Code:

UPDATE thread
SET open = 0
WHERE vb_thread.prefixid = X and vb_forumid=y

Would anyone that actually knows what they're doing mind helping me to create a query to do this? Thanks in advance

Dave 01-04-2017 09:28 PM

It's a lot easier than you think:
HTML Code:

UPDATE thread SET open = 0 WHERE prefixid = X AND forumid = X

Mattwhf 01-05-2017 01:14 AM

Quote:

Originally Posted by Dave (Post 2580346)
It's a lot easier than you think:
HTML Code:

UPDATE thread SET open = 0 WHERE prefixid = X AND forumid = X

Thanks Dave for the codes,

Btw, it is possible to change your codes to close all threads with 1 post or they are old posts with 1 post (I mean it has no answer on its thread)?

kgroneman 01-05-2017 02:04 PM

Quote:

Originally Posted by Dave (Post 2580346)
It's a lot easier than you think:
HTML Code:

UPDATE thread SET open = 0 WHERE prefixid = X AND forumid = X

Thanks! I appreciate the response.:up:

Dave 01-05-2017 02:17 PM

Quote:

Originally Posted by Mattwhf (Post 2580351)
Thanks Dave for the codes,

Btw, it is possible to change your codes to close all threads with 1 post or they are old posts with 1 post (I mean it has no answer on its thread)?

The thread table also stores the lastpost timestamp and the amount of replies in the thread.
For example, the following SQL query will close all threads that are older than 1 week and have no replies:

HTML Code:

UPDATE thread SET open = 0 WHERE replycount = 0 AND lastpost < UNIX_TIMESTAMP(NOW() - INTERVAL 1 WEEK)


All times are GMT. The time now is 05:39 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.03782 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
  • (1)bbcode_code_printable
  • (4)bbcode_html_printable
  • (3)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