On Sat, August 20, 2005 6:33 am, Marcus Bointon wrote: > I'm sorting out some code to handle session object storage, I can't help with the OO stuff. > given that the connection is persistent, and may thus be used by > other scripts, is calling mysql_close a particularly bad idea? Should > I just not bother closing the connection, letting PHP deal with it - > the object will not attempt to re-use the stale connection because it > will get a new instance courtesy of __wakeup when unserialized. The persistence is all on the MySQL side -- From PHP's perspective, it's more like a "re-usable" or a "return for deposit" connection :-) When you "close" the persistent connection, MySQL still keeps around the data structures to re-use it for the next script, which is what "persistent" really means. You don't have to close the connection -- PHP *is* going to close it for you as the script ends. When the same process (Apache child) asks for a connection with the same username/password from MySQL, MySQL can re-use the existing data structures to save the time of building them. That time is actually rather expensive, as it involves a lot of buffers, structures, and, I believe, a fair amount of resource-locking to be sure the current connection will not be in a race condition with other connections for things like mysql_insert_id() and, if you use innoDB, transactions. So saving this time for MySQL to build a connection from scratch instead of using the parts laying around from the last one is the "persistent" connection. HTH NOTE: Be sure you have a few *more* max_connections in /etc/my.cnf than the number of Apache MaxChildren -- Otherwise your Apache children can lock up all the MySQL persistent connections and leave you with Apache children starved for MySQL connection, as well as NO WAY for you to use mysqladmin or mysqldump since *ALL* the available connections are taken up by your Apache server. That's bad. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php