Persistent Database Connection in mysql
we can create persistent database connection by using mysql_pconnect() instead of mysql_connect().
There are only two major difference between mysql_pconnect and mysql_connect.
If we use mysql_pconnect,
1.Connection to the SQL Server won’t be closed until the execution of script ends.We can use same link in future. And also mysql_close() doesn’t close the connection.
2. When we try to establish the connection, mysql_pconnect will check whether connection has established already in the same host with the same username and password. If so the same link will be used, otherwise it will create the new connection.
Advantage of using mysql_pconnect
—————————————————-
- Efficiency,
overhead of establishing connection to SQL server is too high. So if we use mysql_connect(), every page load creates the connection. But if we use mysql_pconnect, only one time only connection is created .
