vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   What querys for # of threads and posts? (https://vborg.vbsupport.ru/showthread.php?t=77797)

Slapyo 03-09-2005 03:29 PM

What querys for # of threads and posts?
 
I want to put the number of threads and posts on the front of my site. I currently have something, but the numbers are off. I assume that it is because of deleted posts and threads. Below are the queries I am using.
Code:

SELECT COUNT(*) AS threads FROM thread
SELECT COUNT(*) AS posts FROM post

However, the numbers are off. On my homepage it shows:
Threads: 477
Posts: 1,531

But on the forum index page at the bottom it shows:
Threads: 463
Posts: 1,529

What are the queries that vBulletin uses to grab that information? I have been digging through the code but I can't seem to find them. I would like the numbers to match.

Zachery 03-09-2005 03:33 PM

Quote:

Originally Posted by Slapyo
I want to put the number of threads and posts on the front of my site. I currently have something, but the numbers are off. I assume that it is because of deleted posts and threads. Below are the queries I am using.
Code:

SELECT COUNT(*) AS threads FROM thread
SELECT COUNT(*) AS posts FROM post

However, the numbers are off. On my homepage it shows:
Threads: 477
Posts: 1,531

But on the forum index page at the bottom it shows:
Threads: 463
Posts: 1,529

What are the queries that vBulletin uses to grab that information? I have been digging through the code but I can't seem to find them. I would like the numbers to match.

Don't forget you need to exlucde delete posts :)

Slapyo 03-09-2005 03:35 PM

Ya, I am just not sure how to do that in the query.

Zachery 03-09-2005 03:43 PM

Quote:

Originally Posted by Slapyo
Ya, I am just not sure how to do that in the query.

Take a look near the bottom of index.php :)

Slapyo 03-09-2005 03:47 PM

great. thanks. i will look there.

ok, so the bottom of index.php had exactly what i want. the # of threads, the # of pots, and the # of users. however, i copy/paste that code into my homepage and it all comes up as 0.

i did print_r on the array and it was full of information, except it didn't have the thread or post info in it like the code says it should.

here is what the top of my file looks like.

PHP Code:

<?php
    
require_once("header.inc.php");
    
chdir("./forums/");
    require_once(
"./global.php");
    require_once(
"./includes/functions_forumlist.php");
    
chdir("../");
    require_once(
"latest_users.inc.php");
    require_once(
"online.php");

    
// Forum Stats

    
$countmembers $DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
    
$totalmembers vb_number_format($countmembers['users']);

//    echo "<pre>";
//    print_r($forumcache);
//    echo "</pre>";

    
$totalthreads 0;
    
$totalposts 0;
    if (
is_array($forumcache))
    {
        foreach (
$forumcache AS $forum)
        {
            
$totalthreads += $forum['threadcount'];
            
$totalposts += $forum['replycount'];
        }
    }
    
$totalthreads vb_number_format($totalthreads);
    
$totalposts vb_number_format($totalposts);

before that it worked, the variable names are the same. i am not sure why the array contains that information in the forums, but not when i call it outside of the forums.

still no dice. i have looked at the different files that are included. on index.php and i have the same files included on my page. but the array on my page still doesn't contain the information that is on the index.php page.

ok, so after digging through the code and seeing the query that gathers the info and stores it into an array, i ran the query myself and parsed it. still no dice. i end up with 0. it seems like the information being stored in the database doesn't contain the information. however the code on index.php says otherwise. so i am confused.

Slapyo 03-10-2005 03:54 PM

Quote:

Originally Posted by Zachery
Take a look near the bottom of index.php :)

Can't seem to get it to work. That code doesn't work when I put it on my page, even though the same files are included in index.php as on my page.

Slapyo 03-11-2005 07:49 PM

i found out the solution. if anyone wants to know it is in my last post in this thread.

https://vborg.vbsupport.ru/showthread.php?t=77916


All times are GMT. The time now is 07:36 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.01869 seconds
  • Memory Usage 1,738KB
  • 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_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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