What is the difference between mysql_connect() and mysql_pconnect()?
When mysql_pconnect() is used, the function initially tries to find an open persistent connection. If found; the identifier is returned. In this case, a new connection is not established. On the other hand, when mysql_connect() is used, a new connection is established.
Using mysql_pconnect(), the connection is not closed to enable future use.
Example:mysql_pconnect("localhost","mysql_user","mysql_pwd");
What is the difference between mysql_connect() and mysql_pconnect()?
The following are the differences -
- A new connection is established to the database by using mysql_connect, where as mysql_pconnect opens a persistant connection to the database.
- mysql_connect can be used to close the connection, where as mysql_pconnect can not close the connection.
- Database is opened every time when the page is loaded by mysql_connect. Whereas by using mysql_pconnect, database need not be connected every time.