NYCPHP Meetup

NYPHP.org

[nycphp-talk] When to close a mysql connection

Jakob Buchgraber jakob.buchgraber at googlemail.com
Sat Jun 30 10:44:25 EDT 2007


David Krings wrote:
> Ben Sgro (ProjectSkyline) wrote:
>> Hello,
>>
>> Doesn't using pconnect take care of this?
>> http://us.php.net/manual/en/function.mysql-pconnect.php
>>
>> What's the best implementation?(provide some source if you can...)
>>
>> - Ben
>>
> 
> I currently have the connection stuff inside of an include file. So I 
> basically would change the line with the mysql_connect to mysql_pconnect 
> and ditch all the mysql_close lines that I have in my script, since 
> mysql_close does not close persistent connections. But then again, how 
> do I close a persistent connection? Uh...found it, the connection gets 
> dropped automatically by MySQL.
> 
> Hmmmmmm, I am not really convinced that this is as good as it sounds. 
> Especially in my current project I allow the active work frame to be 24 
> hours before I force users out (will make that configurable later). I 
> must then set the MySQL timeout to at least the same value, which 
> potentially could cause that MySQL holds many connections.
> 
> Yea, what is the best implementation?
> 
> David
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
> 
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
> 

No mysql doesn't hold many connections then as there is only one 
connection at all when using persistent connections.

- Jakob

-- 
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0



More information about the talk mailing list