]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php
Introduced and implemented findNodeBySessionId()
[hub.git] / application / hub / main / database / wrapper / node / class_NodeDistributedHashTableDatabaseWrapper.php
index 67fd53b26c7a7e949f067552167f538417056502..106b87b36e04d4514c00ee9051649ca78dff7002 100644 (file)
@@ -162,6 +162,30 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                // Update DHT database record
                $this->queryUpdateDataSet($dataSetInstance);
        }
+
+       /**
+        * Finds a node by given session id
+        *
+        * @param       $sessionId      Session id to lookup
+        * @return      $nodeData       Node data array
+        */
+       public function findNodeBySessionId ($sessionId) {
+               // Get search criteria
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Search for session id and limit it to one entry
+               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID, $nodeInstance->getSessionId());
+               $searchInstance->setLimit(1);
+
+               // Query database and get a result instance back
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Return result instance
+               return $resultInstance;
+       }
 }
 
 // [EOF]