Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is disconnecting from the database important, and if so, why?

Status
Not open for further replies.

spewn

Programmer
Joined
May 7, 2001
Messages
1,034
I have written a script that calls the database and retrieve rows. I don't ever use the disconnect:

Code:
$dbh->disconnect();

what, if anything, can result from not disconnecting every time i access the database?

this what i use to access the db:

Code:
$sth = $dbh->prepare("select whatever from table");
$sth->execute;

i call the above script several times, in different variations in the same script.

i'm curious if it's just good practice or if there is a significant reason to disconnect...

thanks!

- g
 
it's good practice to begin with. IF your script exits gracefully I BELIEVE it should take down the DB connection with it. DB's have a limit to how many simultaneous connections they support and you don't want connections being held up just because you didn't put that line in your script do you?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top