I know PHP closes any open MySQL connection at the end of the script execution, but what happens with connections if a fatal error occurs?
I can't find anything here or on Google.
I use static connections to reuse them. Additionally there is a __destruct()
to close it. On the end of the execution, the destructor is called (I see it in the log-file).
But if I do a fatal error (just to find out what happens), the destructor is NOT called. What happens with the connection?
Unless you use persistent connection, mysql connection will always be automatically closed at the end of the script's execution.
PHP Fatal error will stop the script's execution, and mysql connection will be released.
The php engine removes any open connections in case of such a crash. Just as when there is no crash. This is a cleanup thing the engine does. Exception: when using presistent connections then the connection is pooled and reused by subsequent scripts.
The destructor you mention is a destructor in your class, probably some wrapper class. There is no reason why php should call that if it closes the connection to the mysql server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With