]> git.mxchange.org Git - core.git/blobdiff - inc/main/middleware/database/class_DatabaseConnection.php
Continued with renaming-season:
[core.git] / inc / main / middleware / database / class_DatabaseConnection.php
diff --git a/inc/main/middleware/database/class_DatabaseConnection.php b/inc/main/middleware/database/class_DatabaseConnection.php
deleted file mode 100644 (file)
index 7d7686a..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-<?php
-// Own namespace
-namespace CoreFramework\Connection\Database;
-
-// Import framework stuff
-use CoreFramework\Connector\Database\DatabaseConnector;
-use CoreFramework\Criteria\Criteria;
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Database\Backend\DatabaseBackend;
-use CoreFramework\Registry\Registerable;
-use CoreFramework\Middleware\BaseMiddleware;
-use CoreFramework\Middleware\Debug\DebugMiddleware;
-
-/**
- * Database selector class
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Registerable {
-       /**
-        * Array for connection data
-        */
-       private $connectData = array(
-               'login' => '',
-               'pass'  => '',
-               'dbase' => '',
-               'host'  => ''
-       );
-
-       /**
-        * The real database layer
-        */
-       private $dbLayer = NULL;
-
-       /**
-        * An instance of this class
-        */
-       private static $selfInstance = NULL;
-
-       /**
-        * Protected constructor
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates a new database connection layer
-        *
-        * @param       $debugInstance  An instance of a DebugMiddleware class
-        * @param       $dbLayer                An instance of a DatabaseBackend class
-        * @todo        $debugInstance is currently not used
-        */
-       public static final function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseBackend $dbLayer) {
-               // Get instance
-               $databaseInstance = new DatabaseConnection();
-
-               // Set database layer
-               $databaseInstance->setDatabaseLayer($dbLayer);
-
-               // Set db instance
-               self::$selfInstance = $databaseInstance;
-
-               // Return instance
-               return $databaseInstance;
-       }
-
-       /**
-        * Getter for this class
-        *
-        * @return      $selfInstance   An instance of this class
-        */
-       public static final function getSelfInstance () {
-               return self::$selfInstance;
-       }
-
-       /**
-        * 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;
-               $this->connectData['dbase'] = (string) $dbase;
-               $this->connectData['host']  = (string) $host;
-       }
-
-       /**
-        * Getter for connection data
-        *
-        * @return      $connectData    Connection data stored with this clas
-        */
-       public final function getConnectionData () {
-               return $this->connectData;
-       }
-
-       /**
-        * Setter for the real database layer
-        * @param       $dbLayer        An instance of the real database layer
-        * @return      void
-        */
-       public final function setDatabaseLayer (DatabaseBackend $dbLayer) {
-               $this->dbLayer = $dbLayer;
-       }
-
-       /**
-        * Getter for index key
-        *
-        * @return      $indexKey       Index key
-        */
-       public final function getIndexKey () {
-               return $this->dbLayer->getIndexKey();
-       }
-
-       /**
-        * Runs a 'select' statement on the database layer with given table name
-        * and criteria. If this doesn't fail the result will be returned
-        *
-        * @param       $tableName                      Name of the 'table' we shall query
-        * @param       $criteriaInstance       An instance of a Criteria class
-        * @return      $result                         The result as an array
-        */
-       public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Get result from query
-               $result = $this->dbLayer->querySelect($tableName, $criteriaInstance);
-
-               // Return the result
-               return $result;
-       }
-
-       /**
-        * Getter for last exception
-        *
-        * @return      $exceptionInstance      Last thrown exception
-        */
-       public final function getLastException () {
-               $exceptionInstance = $this->dbLayer->getLastException();
-               return $exceptionInstance;
-       }
-
-       /**
-        * 'Inserts' a data set instance into a local file database folder
-        *
-        * @param       $dataSetInstance        A storeable data set
-        * @return      void
-        */
-       public function queryInsertDataSet (StoreableCriteria $dataSetInstance) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Ask the database layer
-               $this->dbLayer->queryInsertDataSet($dataSetInstance);
-       }
-
-       /**
-        * 'Updates' a data set instance with a database layer
-        *
-        * @param       $dataSetInstance        A storeable data set
-        * @return      void
-        */
-       public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Ask the database layer
-               $this->dbLayer->queryUpdateDataSet($dataSetInstance);
-       }
-
-       /**
-        * Getter for primary key column of specified table name
-        *
-        * @param       $tableName              Name of table we need the primary key column from
-        * @return      $primaryKey             Primary key column of requested table
-        */
-       public function getPrimaryKeyOfTable ($tableName) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Ask the database layer
-               $primaryKey = $this->dbLayer->getPrimaryKeyOfTable($tableName);
-
-               // 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) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Call database backend
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: Calling this->dbLayer->removeNonPublicDataFromArray(data) ...');
-               $data = $this->dbLayer->removeNonPublicDataFromArray($data);
-
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: data[]=' . gettype($data));
-               return $data;
-       }
-
-       /**
-        * Count total table rows
-        *
-        * @param       $tableName      Table name
-        * @return      $count          Total row count
-        */
-       public function countTotalRows ($tableName) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Ask the database layer
-               $count = $this->dbLayer->countTotalRows($tableName);
-
-               // Return the value
-               return $count;
-       }
-
-}