Jump to content


Photo

Repeated connect/disconnects


  • Please log in to reply
2 replies to this topic

#1 Buzz

Buzz
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 January 2006 - 06:32 PM

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. :)
[!--sizeo:2--][span style="font-size:10pt;line-height:100%"][!--/sizeo--]Amateurs go until they get it right. Professionals go until they never get it wrong.[!--sizec--][/span][!--/sizec--]

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 31 January 2006 - 07:52 PM

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.

#3 Buzz

Buzz
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 January 2006 - 08:09 PM

[!--quoteo(post=341564:date=Jan 31 2006, 12:52 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Jan 31 2006, 12:52 PM) View Post[/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.
[!--sizeo:2--][span style="font-size:10pt;line-height:100%"][!--/sizeo--]Amateurs go until they get it right. Professionals go until they never get it wrong.[!--sizec--][/span][!--/sizec--]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users