TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   mysql_connect VS. mysql_pconnect (http://www.talkphp.com/absolute-beginners/1770-mysql_connect-vs-mysql_pconnect.html)

ReSpawN 12-19-2007 04:50 PM

mysql_connect VS. mysql_pconnect
 
mysql_connect VS. mysql_pconnect
Well, this should say enough. Which is better? I use pconnect AND connect in the same function. You can define to use it in my inc.connect.php function. Simply set TRUE to use it.

Now the question is, is it safer, faster, smarter, lighter... what is the advantage for real? If you guys can tell me, thanks. :)

Mark

Nor 12-19-2007 04:51 PM

Yeah I'd like to know this also, because I've never used it and people are starting to use it.

sjaq 12-19-2007 06:37 PM

From the php site:
Quote:

Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable).

[....]

If persistent connections don't have any added functionality, what are they good for?

The answer here is extremely simple -- efficiency. Persistent connections are good if the overhead to create a link to your SQL server is high. Whether or not this overhead is really high depends on many factors.
There are some pre's and cons about persistent connections, you just have to read it for yourself :-)

ReSpawN 12-20-2007 03:42 PM

I know enough, thanks!

Matt83 12-22-2007 01:52 PM

"The mysql_pconnect() function was designed to provide a mechanism for reducing the cost of establishing and closing connections to the MySQL server. Unfortunately, due to an interaction between the architecture of the Apache server and the architecture of PHP, high traffic on a site that used pconnects could quickly clog up the MySQL server with many unused connections that could prevent many of the active connections from accessing the database." Zak Greant

webtuto 12-31-2007 11:25 PM

i think pconnect is better for big soks


All times are GMT. The time now is 09:00 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0