vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   MySQL Help - How Would I Optimize this? (https://vborg.vbsupport.ru/showthread.php?t=66610)

hurrican 06-27-2004 11:12 PM

MySQL Help - How Would I Optimize this?
 
When folks register to my site, they have to go through an approval process by me before I Will allow them to post. I Also have it setup when they register, and they are in the "Awaiting E-Mail COnfirmation" group, they receive a special message stating they need to activate their account before they can post, etc. How would I go abouts optimizing this query instead of having three different ones in one pop? Anyone who is able to help is greatly appreciated!

PHP Code:

$forumbits=makeforumbit(intval($forumid), 1$permissions);

$unregwelcomemessage='';
if (
$bbuserinfo['userid']==0) {
  eval(
"\$unregwelcomemessage = \"".gettemplate('forumhome_unregmessage')."\";");
}
$nonactivatedmessage='';
if (
$bbuserinfo['usergroupid']==3) {
  eval(
"\$nonactivatedmessage = \"".gettemplate('awaitconfmessage')."\";");
}
$activatedwaitingapproval='';
if (
$bbuserinfo['usergroupid']==4) {
  eval(
"\$activatedwaitingapproval = \"".gettemplate('awtngadmapprvl')."\";");
}
eval(
"dooutput(\"".gettemplate('forumhome')."\");");

?> 


Xenon 06-28-2004 08:54 PM

erm, there is no mysql query in your post.

there are just php if clauses, but nothing to optimize.

hurrican 06-28-2004 10:14 PM

Quote:

Originally Posted by Xenon
erm, there is no mysql query in your post.

there are just php if clauses, but nothing to optimize.

I'm retarded, lol. I got MySQL and PHP Confused..

That code isn't going to cause any server load issues, will it? I like keeping my users informed when they're in certain usergroups of their status..

Thanks Xenon!! Glad you caught my goof :ermm: :nervous:

Andreas 06-29-2004 04:36 AM

Quote:

Originally Posted by Xenon
erm, there is no mysql query in your post.

Hmm ... and what if forumhome_unregmessage, awaitconfmessage or awtngadmapprvl aren't cached? Then this code will add one additional query ;)

Xenon 06-29-2004 10:14 AM

there is still no mysql query in the code itself :p

@hurrican: well, each line of code let the server work a bit, but it's not noticable, so nothing to do for ya.
But Kirby is right, make sure the templates you are calling are added to the template chache string on the beginning of the script :)

hurrican 06-29-2004 10:07 PM

ok, I don't remember if I did that or not, I'll go back and double check. You guys are great!! I Appreciate your help, and still feel like a dummy, lol!! Hopefully someday i'll be good enough at this stuff to contibute to people like me too :) lol.. Ya'll have a great 4th!! Thanks Again!!

Xenon 06-29-2004 10:36 PM

:)
you're welcome.

Modin 07-01-2004 03:10 PM

it can be optimized by using elseif's or even a switch statement, but it's not really that big of an issue with only 3 if statements...we're talking like pinching a couple bytes of cpu instructions here ;)

Boofo 07-01-2004 03:16 PM

Quote:

Originally Posted by Modin
it can be optimized by using elseif's or even a switch statement, but it's not really that big of an issue with only 3 if statements...we're talking like pinching a couple bytes of cpu instructions here ;)

elseif's I can see. How would you do the switching?

Modin 07-01-2004 03:30 PM

Like so :)

Code:

switch ($bbuserinfo['usergroupid']) {
case 0:
  eval("\$unregwelcomemessage = \"".gettemplate('forumhome_unregmessage')."\";");
  break;
case 3:
  eval("\$nonactivatedmessage = \"".gettemplate('awaitconfmessage')."\";");
  break;
case 4:
  eval("\$activatedwaitingapproval = \"".gettemplate('awtngadmapprvl')."\";");
}

//edit: whooops, had userid instead of usergroupid


All times are GMT. The time now is 12:28 PM.

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.01163 seconds
  • Memory Usage 1,739KB
  • 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)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete