Jump to content

Repeated connect/disconnects


Buzz

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. :)
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.