Jump to content

What if i don't close MySQL database connection ?


terryds

Recommended Posts

I found that the mysql connection will be automatically closed when the php script finish executing the code....Is that right ? How to check if the connection is closed or not? Will it close the connection automatically too if i use PHP Data Objects (PDO) too ?

Link to comment
Share on other sites

All php resources will be destroyed at the end of the script including PDO. It wont matter for small script. But if after opening a connection there is lot of time consuming task your script is doing, connection will be still opened. with that kind of simultanouse call to script can exceed your maximum mysql connection. You can check the variable to see what does it holds to ensure you have active connection or not.

Edited by birbal
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...