X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmiddleware%2Fdatabase%2Fclass_DatabaseConnection.php;h=dd4ce3258c635e8e412c93354732b7c98c7a2a52;hp=e2eaaed9c4c2a2376e3754eb6986bf70774aaf22;hb=a97ce31e3e0e4e419870d45e676ef470b8324715;hpb=0cd57c3885f00ad77fc599e53ed2f2d5e7ac267f diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php index e2eaaed9..dd4ce325 100644 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -2,11 +2,11 @@ /** * Database selector class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,42 +33,39 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re ); // The real database layer - private $dbLayer = null; + private $dbLayer = NULL; // An instance of this class - private static $thisInstance = null; + private static $selfInstance = NULL; /** * Protected constructor * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } // Create new database connection layer - public final static function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseFrontendInterface $dbLayer) { + public static final function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseBackend $dbLayer) { // Get instance - $dbInstance = new DatabaseConnection(); - - // Set debug output handler - $dbInstance->setDebugInstance($debugInstance); + $databaseInstance = new DatabaseConnection(); // Set database layer - $dbInstance->setDatabaseLayer($dbLayer); + $databaseInstance->setDatabaseLayer($dbLayer); // Set db instance - self::$thisInstance = $dbInstance; + self::$selfInstance = $databaseInstance; // Return instance - return $dbInstance; + return $databaseInstance; } // Get an instance of this class - public final static function getInstance () { - return self::$thisInstance; + public static final function getSelfInstance () { + return self::$selfInstance; } // Public setter for database connection @@ -94,7 +91,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re * @param $dbLayer An instance of the real database layer * @return void */ - public final function setDatabaseLayer (DatabaseFrontendInterface $dbLayer) { + public final function setDatabaseLayer (DatabaseBackend $dbLayer) { $this->dbLayer = $dbLayer; } @@ -120,7 +117,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re $this->dbLayer->connectToDatabase(); // Get result from query - $result = $this->dbLayer->querySelect('array', $tableName, $criteriaInstance); + $result = $this->dbLayer->querySelect($tableName, $criteriaInstance); // Return the result return $result; @@ -180,6 +177,17 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re // Return the value return $primaryKey; } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray (array $data) { + // Call database backend + return $this->dbLayer->removeNonPublicDataFromArray($data); + } } // [EOF]