0

接続が確立されたかどうか、および接続が閉じられたかどうかを示すphpアプリケーションからのMySQL接続を監視するツールがあるかどうかを知りたいです。

目標は、接続が開かれたときにジョブが完了した後に閉じられるようにアプリケーションを修正することです。

何か案は?

4

1 に答える 1

1

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.

于 2012-06-08T17:57:44.697 に答える