PDA

View Full Version : queries in my phpinclude template


corsacrazy
04-16-2003, 08:26 AM
ok ! i hav some stats in my header ! so to generate them ive used the phpinclude template so therefore my stats show on every page of forums . i know for a fact these stats add 10 queries therefor 10 queries to EVERYPAGE

what php FILE shall i move these queries to from my phpinclude template so it shows on everypage ? is it funcions.php ? by doing this will it reduce query count ? thanks in advance

Xenon
04-16-2003, 10:36 AM
you should put it into global.php
but no it wouldn reduce the ammount of queries, just the position of them ^^

you should optimize the stats to reduce the queries...

corsacrazy
04-16-2003, 11:01 AM
any ideas on how to optimise the stats ?

Erwin
04-16-2003, 01:25 PM
10 queries on every page? For stats? Not worth it... something isn't right. Post your queries here.

Xenon
04-16-2003, 01:58 PM
maybe we can optimize it, but as Erwin said you have to post them or we don't know ;)

corsacrazy
04-16-2003, 03:35 PM
k

this is my php include template :D

// This code is PHP4 only:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();
include("vbs_counter.php");
// Lets query the DB for post count.
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
// For threads.
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
// For members
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
// End Advanced header info (mod by Anime-loo)

$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];

// Top poster
$topposters=$DB_site->query_first("SELECT username,posts,userid FROM user ORDER BY posts desc LIMIT 1");

// number of posts today
$datecut = mktime(0,0,0,date("m"), date("d"), date("y"));
$getpoststoday=$DB_site->query_first("SELECT count(*) AS count FROM post WHERE dateline>='$datecut'");
$poststoday=$getpoststoday[count];

if (strpos($_SERVER['PHP_SELF'], 'index.php') != false)
{
$totalchars = $DB_site->query("SELECT SUM(LENGTH(pagetext)) AS totalchars FROM post");
$totalchars = $DB_site->fetch_array($totalchars);
$totalchars = number_format($totalchars['totalchars']);
}
$usersig = bbcodeparse2($bbuserinfo[signature], "1", "1", "1", "1");

// number of posts yesterday
$datecut = mktime(0,0,0,date("m"), date("d"), date("y"));
$getpostsyesterday=$DB_site->query_first("SELECT count(*) AS count FROM post WHERE dateline<='$datecut' AND dateline>=".($datecut-24*3600));
$postsyesterday=$getpostsyesterday[count];

Xenon
04-16-2003, 11:56 PM
ouch ^^

well the total post count and total thread count can be combined into one, look into my optimizing forumhome hack.

the newest user should be cached

the sum postchars is a very slow query and shouldn't be there at all...

i don't think those stats are really needed and should be removed at all for performance issues...

Erwin
04-17-2003, 12:02 AM
Why have these stats on EVERY page??? Just have it in your index.php on the forumhome. Even then, too many stats.

corsacrazy
04-17-2003, 08:05 AM
tru :( i will be sad to see them go :( if i just want these to appear on forumhome which file do i add these to index.php ?

Erwin
04-17-2003, 08:09 AM
Yes. index.php. As long as members don't miss it, and your server doesn't suffer. :)

corsacrazy
04-17-2003, 08:49 AM
members will miss it however i wqas tired of havin 36 queries on forumhome