PDA

View Full Version : Simple Stars hack, too many querys being generated...


Kinox
06-29-2002, 06:11 PM
ok, this code generates too many queries, how can I lower it down?

for every usertitle it generates 1 queries, leats say I have 15 replys in 1 thread, that will generate 15 queries...

is there a way to lower it down?

global $DB_site;
$gettitles = $DB_site->query_first("SELECT minposts,image,setimages FROM usertitle WHERE minposts<=$post[posts] ORDER BY minposts DESC LIMIT 1");
if ($post[posts] > $gettitles[minposts]) {
$findusertitle = "<br>";
for ($i=0; $i<$gettitles[setimages]; $i++) {
$findusertitle .= "<img src=\"https://vborg.vbsupport.ru/greentek/titles/$gettitles[image].gif\">";
} // end if
} // end if
$post[usertitle] .= $findusertitle;

Logician
06-30-2002, 08:29 PM
what about hard coding instead of making queries to MYSQL?

Kinox
07-01-2002, 06:38 AM
well if I do that, its not very user friendly, you would had to edit it by hand to add stars to ranks...

can I loop this somehow without making too many queries?

Logician
07-01-2002, 08:29 AM
I think having a performance-friendly code is better than a user-friendly code.

However if you are determined to use queries all you can do is to mimic vb's behaviour of handling user signatures in posts. That is, after making your query and returning your result from MYSQL, store it in an array (cache) and before making any further queries, first check your array if the value already pulled and exist.

This will reduce the number of queries..

Kinox
07-01-2002, 10:38 AM
thanks, could you give me a code example?