vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Post Count SQL Query (https://vborg.vbsupport.ru/showthread.php?t=281942)

MattGarner 04-23-2012 11:12 AM

Post Count SQL Query
 
I did this before but a user went missing during a database crash and we had to bring the user back. But their post count says 0 and I remember running a query to fix that but can no longer find what I used. Could someone let me know what it is again?

Cheers!

kh99 04-23-2012 11:41 AM

You could use Maintenance -> General Update Tools -> Update Post Counts to recalculate it for all users.

If you want to do it manually for one user you could use this query:

Code:

SELECT COUNT(*) AS posts FROM post
    INNER JOIN thread ON (thread.threadid = post.threadid)
    WHERE post.userid = ID
    AND thread.visible = 1
    AND post.visible = 1

(obviously replace ID with the user's id) then enter the resulting count using the user manager (You could have a query to set the value, and maybe even one query to calculate and set in one operation, but it doesn't seem worth figuring it out).

I should mention that I looked at the code in admincp/misc.php that recalculates user post count when you do it form the maintenance menu, and it accounts for any forums marked as not included in user post counts, while the query above doesn't. So if you have any forums like that you probably just want to use the maintenance menu.


All times are GMT. The time now is 06:07 AM.

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.00908 seconds
  • Memory Usage 1,708KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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