// Import framework stuff
use CoreFramework\Registry\Registerable;
+use CoreFramework\Middleware\BaseMiddleware;
/**
* Database selector class
* 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();
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;