when should i use mysql_pconnect and when to use mysql_connect
?
what the execlly diffrence and how does it influence performance?
thnaks in advance
peleg
what /when to use mysql_pconnect?
Moderator: General Moderators
-
Robert Plank
- Forum Contributor
- Posts: 110
- Joined: Sun Dec 26, 2004 9:04 pm
- Contact:
- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
can you please
maybe reffer to an article that explains the diffrence or maybe explain in some simple words?
I've used persistant connections (in connection pools) with other languages, but am yet to find myself needing to use it in PHP.
The short answer, which doesn't help, is: "Only when you need to use a persistant connection" :p
I do know of Yahoo! sized sites using connection pools in PHP (thus use mysql_pconnect,) but due to the nature in which PHP operates, I'm not sure on how they achieve the same result as using a connection pool ala J2EE. Simply because PHP is a Script-language and only operates on a request basis.. i.e. your send a request, it responds then terminates.
Unless there is a side to PHP I am oblivious to.
The differences are quite simple, but the implications, and reasons to use either over the other are not so simple:
mysql_connect - connection is made and is automagically closed upon script termination.
mysql_pconnect - connection is made, and is only closed when mysql_close is called (and the relevant connection identifier used.) The engine will actively maintain this connection so it does not close, until a preset timeout period expires, or the mysql_close command used.
The short answer, which doesn't help, is: "Only when you need to use a persistant connection" :p
I do know of Yahoo! sized sites using connection pools in PHP (thus use mysql_pconnect,) but due to the nature in which PHP operates, I'm not sure on how they achieve the same result as using a connection pool ala J2EE. Simply because PHP is a Script-language and only operates on a request basis.. i.e. your send a request, it responds then terminates.
Unless there is a side to PHP I am oblivious to.
The differences are quite simple, but the implications, and reasons to use either over the other are not so simple:
mysql_connect - connection is made and is automagically closed upon script termination.
mysql_pconnect - connection is made, and is only closed when mysql_close is called (and the relevant connection identifier used.) The engine will actively maintain this connection so it does not close, until a preset timeout period expires, or the mysql_close command used.