Re: MySQL close connection, what's the purpose?

From: Date: Sat, 01 Apr 2006 23:07:43 +0000
Subject: Re: MySQL close connection, what's the purpose?
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-233069@lists.php.net to get a copy of this message
tedd wrote:
I always close the connection right after my
query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble.
So you close it after every query and then re-open it later for the next query? I don't see that as a good idea.
No, you leave it open until you're done with the database.
Reading Ted's post didn't give this impression. I wanted to make sure he wasn't doing it that way.
Chris et al: Actually I am. When I need something from the dB, I open it, get the information and close it. It's like opening a drawer, getting what you need, and then closing the drawer. Where's the problem?
Uh, what if you want to do more than one query in a single request? You aren't seriously suggesting you would connect and disconnect from the same database multiple times within the same request? In my experience, connecting to the database takes up more than half of the execution time of the average database-driven PHP script (I said *average*, there are exceptions). You don't want to be doing it multiple times if you don't have to. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM jasper@album.co.nz 021 708 334

« previous php.general (#233069) next »