Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2004, 11:12 PM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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')."\");");

?> 
Reply With Quote
  #2  
Old 06-28-2004, 08:54 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

erm, there is no mysql query in your post.

there are just php if clauses, but nothing to optimize.
Reply With Quote
  #3  
Old 06-28-2004, 10:14 PM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Reply With Quote
  #4  
Old 06-29-2004, 04:36 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 06-29-2004, 10:14 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

there is still no mysql query in the code itself

@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
Reply With Quote
  #6  
Old 06-29-2004, 10:07 PM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!!
Reply With Quote
  #7  
Old 06-29-2004, 10:36 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default


you're welcome.
Reply With Quote
  #8  
Old 07-01-2004, 03:10 PM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 07-01-2004, 03:16 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #10  
Old 07-01-2004, 03:30 PM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05387 seconds
  • Memory Usage 2,257KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete