canadium Posted May 19, 2006 Share Posted May 19, 2006 Hey everyone. I'm running a site engine with a bunch of different queries, maybe around 25 queries per page view. I am planning to expand to a site with around 100+.This isn't huge... but I'm just wondering, is it better to do a connect and close mysql command before and after EACH query, or is it better to do one connect command at the beginning of page execution and a close command at the end? I'm curious about security and efficiency. Is doing more queries a lot more intensive on the server, and if I do one connect and one close is that leaving myself open to attacks?Thanks,-Will Quote Link to comment https://forums.phpfreaks.com/topic/9981-more-connects-better-or-less/ Share on other sites More sharing options...
jeremywesselman Posted May 19, 2006 Share Posted May 19, 2006 I'll tell you right now that is more effecient to open one connection at the beginning of the page and close it at the end of the page then it is to open and close a new connection for each query. I'm not sure about security, but I don't think you'll have a problem using just one connection per page instead of one connection per query.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment https://forums.phpfreaks.com/topic/9981-more-connects-better-or-less/#findComment-37085 Share on other sites More sharing options...
canadium Posted May 19, 2006 Author Share Posted May 19, 2006 [!--quoteo(post=375147:date=May 19 2006, 12:43 AM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ May 19 2006, 12:43 AM) [snapback]375147[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'll tell you right now that is more effecient to open one connection at the beginning of the page and close it at the end of the page then it is to open and close a new connection for each query. I'm not sure about security, but I don't think you'll have a problem using just one connection per page instead of one connection per query.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--][/quote]OK, thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/9981-more-connects-better-or-less/#findComment-37092 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.