]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-connect.php
Began to rewrite whole script for newly added filters, new extension stub 'network...
[mailer.git] / inc / mysql-connect.php
index d8de0073a218d89792dbd69134db25bb6f1cc7e8..fc86b7eb4ab39bdc5602d53be77962b0508f9596 100644 (file)
@@ -83,14 +83,24 @@ function __errorHandler ($errno, $errstr, $errfile, $errline) {
 // Set error handler
 set_error_handler('__errorHandler');
 
-// Call-back function for running shutdown functions
-function __RUN_SHUTDOWN_FILTER () {
+// Call-back function for running shutdown functions and close database connection
+function __SHUTDOWN_HOOK () {
+       global $link;
+
        // Call the filter chain 'shutdown'
        RUN_FILTER('shutdown', null, false);
+
+       if (is_resource($link)) {
+               // Close link
+               SQL_CLOSE($link, __FILE__, __LINE__);
+       } else {
+               // No database link
+               ADD_FATAL(NO_DB_LINK);
+       }
 }
 
 // Register shutdown hook
-register_shutdown_function('__RUN_SHUTDOWN_FILTER');
+register_shutdown_function('__SHUTDOWN_HOOK');
 
 // Check if the user setups his MySQL stuff...
 if ((empty($MySQL['login'])) && (!defined('mxchange_installing')) && (!isset($_GET['installing'])) && (isBooleanConstantAndTrue('mxchange_installed'))) {