PDA

View Full Version : total thread views


BaldNut
05-25-2002, 12:02 PM
what is the code i would add into my stats panel to have the total thread views info please.

Visionray
12-04-2002, 02:50 AM
bump

Automated
03-28-2003, 11:06 AM
i would like this too! Kinda like what they have here at VB.org

Xenon
03-28-2003, 12:57 PM
open index.php
find:
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);


change to:
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads, SUM(views) AS views FROM thread');
$totalthreads=number_format($countthreads['threads']);
$totalviews=number_format($countthreads['views']);


then put $totalviews to you templates :)

Darwinist
04-13-2003, 01:38 AM
I got errors when I used the code. I fixed it with this...

$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads, SUM(views) AS views FROM thread');
$totalthreads=number_format($countthreads['threads']);
$totalviews=number_format($countthreads['views']);

..."number_format(" doesn't show up under the PHP vB Code statement.

Mijae
04-13-2003, 02:42 AM
Would this add an extra query to forumhome?

Logician
04-13-2003, 08:45 AM
Today at 06:36 AM v0id said this in Post #6 (https://vborg.vbsupport.ru/showthread.php?postid=381289#post381289)
Would this add an extra query to forumhome?
yes.. everytime you see a line "$DB_site->query" within a code, you can safely regard, you added a query to that page.

Darwinist
04-13-2003, 11:49 AM
The "$DB_site->query" was there already... the line wasn't added, only changed.

Logician
04-13-2003, 11:54 AM
Today at 03:43 PM pgt91 said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=381402#post381402)
The "$DB_site->query" was there already... the line wasn't added, only changed.
ok then reverse logic: since there is no new "$DB_site->query" line, there is no extra query added.. ;)

Xenon
04-13-2003, 03:56 PM
even so it's a slow query, which will slow down loading forumhome a bit.

i'm not a fan of threadviews on forumhome because it isn't really usefull and just slows down the page....

BaldNut
04-13-2003, 04:25 PM
Today at 05:50 PM Xenon said this in Post #10 (https://vborg.vbsupport.ru/showthread.php?postid=381489#post381489)
even so it's a slow query, which will slow down loading forumhome a bit.

i'm not a fan of threadviews on forumhome because it isn't really usefull and just slows down the page....


You got on your own Forum Home.

Thanks guys,

worked a treat, and gutted at only 38,000 views :( 5 million on vbull.org

Xenon
04-13-2003, 06:18 PM
Baldnut: yes, but i don't use that query above, on vb.org i've cached the value, and just read out from a cache and just updates the cache once in an hour.

that way i've increased the speed of forumhome and with some other optimization i did, the queryammount is equal to an uncached version :)

BaldNut
04-13-2003, 08:08 PM
nice one :) i wasnt being nasty btw :)

Xenon
04-14-2003, 03:43 PM
no prob ;)

i just wanted to say that ;)

i did some explain querie checks to optimize our vb.org forumhome and saw that this thing was the 2nd slowest querie on the page (the slowest was the styledropdown) ;)