Jump to Navigation

001 - mysql_connect() and mysql_pconnect()

There is a difference between mysql_connect() and mysql_pconnect().

* mysql_connect()
This opens a connection to a MySQL Server. The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close().

* mysql_pconnect()
This is much like mysql_connect(), but there are two major differences. mysql_pconnect() opens a persistent MySQL connection. This would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, this will be returned instead of opening a new connection. The connection will not be closed when the execution of the script ends. It means mysql_close() will not close connection opened by mysql_pconnect(). It will stay open for future use.

MySQL:


Main menu 2

Story | by Dr. Radut