]> git.mxchange.org Git - core.git/blobdiff - inc/main/middleware/database/class_DatabaseConnection.php
Continued:
[core.git] / inc / main / middleware / database / class_DatabaseConnection.php
index b695c867eb12d7060eca3dfe184276d5d0e8ac4e..d6e847cc2f80efb0021613bab8882ce8dbcf86ef 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Connection\Database;
 
 // Import framework stuff
 use CoreFramework\Registry\Registerable;
+use CoreFramework\Middleware\BaseMiddleware;
 
 /**
  * Database selector class
@@ -32,29 +33,36 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
         * Array for connection data
         */
        private $connectData = array(
-               'login' => '',
-               'pass'  => '',
-               'dbase' => '',
-               'host'  => ''
+               'login' => '',
+               'pass'  => '',
+               'dbase' => '',
+               'host'  => ''
        );
 
-       // The real database layer
+       /**
+        * The real database layer
+        */
        private $dbLayer = NULL;
 
-       // An instance of this class
+       /**
+        * An instance of this class
+        */
        private static $selfInstance = NULL;
 
        /**
         * Protected constructor
-        *
-        * @return      void
         */
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
 
-       // Create new database connection layer
+       /**
+        * Creates a new database connection layer
+        *
+        * @param       $debugInstance  An instance of a DebugMiddleware class
+        * @param       $dbLayer                An instance of a DatabaseBackend class
+        */
        public static final function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseBackend $dbLayer) {
                // Get instance
                $databaseInstance = new DatabaseConnection();
@@ -69,13 +77,26 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
                return $databaseInstance;
        }
 
-       // Get an instance of this class
+       /**
+        * Getter for this class
+        *
+        * @return      $selfInstance   An instance of this class
+        */
        public static final function getSelfInstance () {
                return self::$selfInstance;
        }
 
-       // Public setter for database connection
-       public final function setConnectionData ($login, $pass, $dbase, $host='localhost') {
+       /**
+        * Setter for all database connection data. All these parameters may be
+        * supported by the underlaying backend.
+        *
+        * @param       $login  Login name to database
+        * @param       $pass   Passwort for above login
+        * @param       $dbase  Name of used database
+        * @param       $host   Host to connect to (default: 127.0.0.1)
+        * @return      void
+        */
+       public final function setConnectionData ($login, $pass, $dbase, $host = '127.0.0.1') {
                // Transfer connection data
                $this->connectData['login'] = (string) $login;
                $this->connectData['pass']  = (string) $pass;