Buzz Posted January 31, 2006 Share Posted January 31, 2006 I am currently in the process of designing a MySQL database. I am very new at using PHP (or any language) to connect to a database in this manner. My web site isn't going to have any form of logging in or "sessions" or whatnot. So, I am wondering: Is it bad/slow to connect, perform one operation (i.e. search the database as a visitor to the site), and then disconnect? Or is that typical? Should the connection be left open so visitors can perform multiple searches until they are done? (In such a case, how/when would I close the connection?)Thanx in advance. If any of that was confusing, please say so. :) Quote Link to comment https://forums.phpfreaks.com/topic/3297-repeated-connectdisconnects/ Share on other sites More sharing options...
wickning1 Posted January 31, 2006 Share Posted January 31, 2006 Any open connections are closed when the PHP script finishes its execution. There is no need to disconnect, the ability is only there for people who need to free up resources ASAP.New database connections are costly in high-performance situations but insignificant for most people. Don't worry about it until you have more experience. Quote Link to comment https://forums.phpfreaks.com/topic/3297-repeated-connectdisconnects/#findComment-11233 Share on other sites More sharing options...
Buzz Posted January 31, 2006 Author Share Posted January 31, 2006 [!--quoteo(post=341564:date=Jan 31 2006, 12:52 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Jan 31 2006, 12:52 PM) [snapback]341564[/snapback][/div][div class=\'quotemain\'][!--quotec--]Any open connections are closed when the PHP script finishes its execution. There is no need to disconnect, the ability is only there for people who need to free up resources ASAP.New database connections are costly in high-performance situations but insignificant for most people. Don't worry about it until you have more experience.[/quote]Wow, thanx for that. Yeah, my database won't be that extensive so I guess I don't need to worry. Thanx for the prompt response. Quote Link to comment https://forums.phpfreaks.com/topic/3297-repeated-connectdisconnects/#findComment-11234 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.