and rewritten to functions
[mailer.git] / inc / mysql-connect.php
index fdc059a8fb27904640f3cce2499486a0081d2199..cb41c079d1ca69b262df774e57bd44aa72067957 100644 (file)
@@ -83,14 +83,12 @@ set_error_handler('__errorHandler');
 
 // 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)) {
+       if (SQL_IS_LINK_UP()) {
                // Close link
-               SQL_CLOSE($link, __FILE__, __LINE__);
+               SQL_CLOSE(__FILE__, __LINE__);
        } else {
                // No database link
                addFatalMessage(getMessage('NO_DB_LINK'));
@@ -140,17 +138,12 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
 
        if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) {
                // Connect to DB
-               global $link;
-               $link = SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__);
+               SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__);
 
                // Is the link valid?
-               if (is_resource($link)) {
-                       // Choose the database
-                       global $db;
-                       $db = SQL_SELECT_DB($MySQL['dbase'], $link, __FILE__, __LINE__);
-
+               if (SQL_IS_LINK_UP()) {
                        // Is it a valid resource?
-                       if ($db === true) {
+                       if (SQL_SELECT_DB($MySQL['dbase'], __FILE__, __LINE__) === true) {
                                // This is required for extension 'optimize' to work
                                define('__DB_NAME', $MySQL['dbase']);
 
@@ -247,7 +240,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
 
                        // No link to database!
                        addFatalMessage(getMessage('NO_DB_LINK'));
-                       $db = false;
                }
        } else {
                // Add language system
@@ -263,7 +255,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
 
        // Set other missing variables
        if (!isset($GLOBALS['output_mode'])) $GLOBALS['output_mode'] = "0";
-       $link = false; // No database link by default
 
        // Include required files
        LOAD_INC_ONCE("inc/databases.php");