]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/middleware/database/class_DatabaseConnection.php
CAPTCHA now works in registration form
[shipsimu.git] / inc / classes / middleware / database / class_DatabaseConnection.php
index 87e89f2753122d1d8bbc43f057cdab1fc09f536a..7a9300f1615718035f928730af2fb6bfd85f4e7a 100644 (file)
@@ -6,7 +6,7 @@
  * @version            0.0.0
  * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.ship-simu.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
@@ -21,7 +21,7 @@
  * 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, LimitableObject {
+class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Registerable {
        /**
         * Array for connection data
         */
@@ -51,7 +51,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
                $this->setObjectDescription("Datenbank-Mittelschicht");
 
                // Create an unique ID
-               $this->createUniqueID();
+               $this->generateUniqueId();
        }
 
        // Create new database connection layer
@@ -96,34 +96,12 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
        }
 
        /**
-        * Save a whole object or parts of it to the database or local file
-        *
-        * @param       $object         The object we shall save
-        * @return      void
-        */
-       public function saveObject (FrameworkInterface $object) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // For now just pipe it through to the database layer
-               $this->dbLayer->saveObject($object);
-       }
-
-       /**
-        * Set a limitation for the saving process. This shall be done before
-        * saveObject() is called else saveObject() shall save the whole object.
-        *
-        * @param       $limitInstance  An instance of ObjectLimits which contains
-        *                                                      elements we shall exclusivly include in
-        *                                                      saving process
+        * Setter for the real database layer
+        * @param       $dbLayer        An instance of the real database layer
         * @return      void
         */
-       public function limitObject (ObjectLimits $limitInstance) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // For now we pipe this through to the real database instance
-               $this->dbLayer->limitObject($limitInstance);
+       public final function setDatabaseLayer (DatabaseFrontendInterface $dbLayer) {
+               $this->dbLayer = $dbLayer;
        }
 
        /**
@@ -145,32 +123,6 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
                return $this->dbLayer->isUniqueIdUsed($uniqueID, $inConstructor);
        }
 
-       /**
-        * Gets cached data from the database layer and if not found fetch it from
-        * the database again. This method does not return the header stuff because
-        * the underlaying database class will return only the requested content.
-        *
-        * @param       $idNumber               The ID number which we need for looking up
-        *                                                      the requested data
-        * @return      $cachedArray    The maybe cached data from the database
-        */
-       public function getObjectFromCachedData ($idNumber) {
-               // Connect to the database
-               $this->dbLayer->connectToDatabase();
-
-               // Pass the returning result through
-               return $this->dbLayer->getObjectFromCachedData($idNumber);
-       }
-
-       /**
-        * Setter for the real database layer
-        * @param       $dbLayer        An instance of the real database layer
-        * @return      void
-        */
-       public final function setDatabaseLayer (DatabaseFrontendInterface $dbLayer) {
-               $this->dbLayer = $dbLayer;
-       }
-
        /**
         * Runs a "select" statement on the database layer with given table name
         * and criteria. If this doesn't fail the result will be returned
@@ -206,12 +158,26 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Li
         * @param       $dataSetInstance        A storeable data set
         * @return      void
         */
-       public function insertDataSet (StoreableCriteria $dataSetInstance) {
+       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->insertDataSet($requestInstance);
+               $this->dbLayer->queryUpdateDataSet($dataSetInstance);
        }
 }