Persistent Database Connection in mysql

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 .

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.