Connecting Tech Pros Worldwide Help | Site Map

Permanent MySQL Connection

TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 913
#1: Jul 1 '08
Hey guys
Long time no see, hope you are all well. Been pretty busy at work, so not much time to continue all my programming adventures!

I do however want to re-focus on it and I was wondering if there is any extra danger I should know about in using a permanent connection (only have to connect to the db once by replacing mysql_connect with mysql_pconnect)?
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Jul 1 '08

re: Permanent MySQL Connection


Heya, TheServant.

Check out the comments on the PHP manual page for mysql_pconnect() (http://php.net/mysql_pconnect).

Especially this one (http://php.net/manual/en/function.my...nect.php#39599).

Also note that SQL variables and temporary tables might not work the way you expect them to; connections will be persistent but that does not mean that mysql_pconnect() will return the same one every time!.
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 913
#3: Jul 1 '08

re: Permanent MySQL Connection


Cheers. So from that second link, the general feel is you shouldn't use it unless you have to? I am connecting on every page and grabbing data from tables at the beginning too. I won't change the data grabbing, but I just figured it would be more efficient to have a permanent connection?

From the php manual it seems to suggest there is no efficiency advantages? Can I just get someone to confirm this before I forget about using it?
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Jul 1 '08

re: Permanent MySQL Connection


Check out this article (http://www.mysql.com/news-and-events...000000086.html).
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 913
#5: Jul 1 '08

re: Permanent MySQL Connection


Sold. Thanks for your help, I will remember what I have learned but not use this, for the simple reason it does not improve what I wanted to improve.

The Servant
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Jul 2 '08

re: Permanent MySQL Connection


We aim to please.

Good luck with your project, and if you ever need anything, post back anytime (:
Reply