mysql_pconnect as I read does not close when the mysql_query ceases.. in that case why do we use this command?? does that create any security issue??
mysql_pconnect as I read does not close when the mysql_query ceases.. in that case
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, it’s worth noting that persistent connections are not MySQL-specific.
What’s their purpose? They allow to reuse a database connection in different script calls. Otherwise, scripts must open new connections every time they’re executed. This is particularly useful when opening a new connection is an expensive operation.
In my personal experience, they should be avoided when coding with PHP and MySQL for these reasons:
PHP does a very poor handling of the connection pool and you’re likely to have a hundred idle connections that are not being reused.
MySQL allows to open new connections pretty quickly compared to other DBMS.
I’m not sure about what security issues you have in mind. In order to reuse an idle connection, your PHP script needs to provide the same credentials that were used to open it. If script A opens a connection as root, script B cannot use it with other user.