Reputation: 14466
I would like to know if there is any kind of tool to monitor the MySQL connections from php application that shows the connections made and if the connections closed or not.
Goal is to fix the application so that when a connection is opened, it is closed after the job is done.
Any ideas?
Upvotes: 0
Views: 488
Reputation: 15359
You can use PDO to create your connections, and when they either go out-of-scope or are set to null
they will be closed automatically.
From the linked manual page (emphasis added):
Upon successful connection to the database, an instance of the PDO class is returned to your script. The connection remains active for the lifetime of that PDO object. To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted--you do this by assigning NULL to the variable that holds the object. If you don't do this explicitly, PHP will automatically close the connection when your script ends.
Upvotes: 1