]> git.mxchange.org Git - hub.git/commitdiff
First attempt to store session id in database
authorRoland Häder <roland@mxchange.org>
Mon, 3 Aug 2009 21:32:10 +0000 (21:32 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 3 Aug 2009 21:32:10 +0000 (21:32 +0000)
application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php
application/hub/main/nodes/class_BaseHubNode.php

index a9d279de7fd3ce9311f373de7999fde1781b71b8..e8550f28152917397de10c1452b402bf562e5cbb 100644 (file)
@@ -26,9 +26,10 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper {
        const DB_TABLE_NODE_INFORMATION = 'node_data';
 
        // Constants for database column names
-       const DB_COLUMN_NODE_NR   = 'node_nr';
-       const DB_COLUMN_NODE_ID   = 'node_id';
-       const DB_COLUMN_NODE_TYPE = 'node_type';
+       const DB_COLUMN_NODE_NR    = 'node_nr';
+       const DB_COLUMN_NODE_ID    = 'node_id';
+       const DB_COLUMN_SESSION_ID = 'session_id';
+       const DB_COLUMN_NODE_TYPE  = 'node_type';
 
        /**
         * Protected constructor
@@ -86,6 +87,28 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper {
                // "Insert" this request instance completely into the database
                $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
        }
+
+       /**
+        * 'Registers' a new session id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           A node instance
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance) {
+               // Get a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
+
+               // Set the primary key
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Add registration elements to the dataset
+               $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance);
+
+               // "Insert" this request instance completely into the database
+               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+       }
 }
 
 // [EOF]
index 13bdbf75b22fd7a382f72679c84f9d7b00d660c2..ecf088899c3c1d27999a025ed6154b29fe4c6e7b 100644 (file)
@@ -264,7 +264,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
 
                // Register the node id with our wrapper
-               $wrapperInstance->registerNodeId($this, $this->getRequestInstance());
+               $wrapperInstance->registerSessionId($this, $this->getRequestInstance());
 
                // Output message
                $this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');