Hi
I am learning MySQL transaction with PHP. I understand that there are two ways to make a connection with MySQL. One of them is using mysql_connect, and the other is mysql_pconnect.
In PHP manual, and in every books that I reviewed, they said when I use musql_pconnect, a persistent connection will be established, and when the execute of script ends, it remains for future use. I can't close the connection by mysql_close function, too.
My question is here: Does this matter a risk for my data security? When I establish a persistent connection, it still open after my script end, so can others access to my database? I know there is a limitation for active connections in MySQL and Apache systems (I think it is about 100 connections), so it is better to use a persistent connection. But is there any security to protect my data from others?
How can I close a persistent connection?
Thanks
mysql_connect or mysql_pconnect?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You can't close a persistant connection via your script. The benefits of having a persistant connection are not as great as they would first seem. Have a read of this:
http://www.php.net/manual/en/features.p ... ctions.php
Having a limit to the number of connections may in fact be a reason not to use persistant connections - if you have lots of open connections it will prevent the 101'th person from connecting. Some hosts disallow persistant connections for this reason.
Whether it is better to use mysql_pconnect() over mysql_connect() is governed by a number of factors so what may be right for one person's setup will not be for another's.
Mac
http://www.php.net/manual/en/features.p ... ctions.php
Having a limit to the number of connections may in fact be a reason not to use persistant connections - if you have lots of open connections it will prevent the 101'th person from connecting. Some hosts disallow persistant connections for this reason.
Whether it is better to use mysql_pconnect() over mysql_connect() is governed by a number of factors so what may be right for one person's setup will not be for another's.
Mac