Jump to content

Archived

This topic is now archived and is closed to further replies.

Buzz

Repeated connect/disconnects

Recommended Posts

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. :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.