]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php
Introduced (cached) method ifNodeDataIsFound()
[hub.git] / application / hub / main / database / wrapper / node / class_NodeInformationDatabaseWrapper.php
index 03447d81d5b9815499dc9406bdffe1693c26d53e..4491ef22284e9b0290a2b67a4fa538aabcda137b 100644 (file)
@@ -59,6 +59,37 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node
                return $wrapperInstance;
        }
 
+       /**
+        * Checks whether there is an entry for given node instance
+        *
+        * @param       $nodeInstance   An instance of a NodeHelper class
+        * @return      $isFound                Whether a node id has been found for this node
+        */
+       public function ifNodeDataIsFound (NodeHelper $nodeInstance) {
+               // Is there cache?
+               if (!isset($GLOBALS[__METHOD__])) {
+                       // Now get a search criteria instance
+                       $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+                       // Search for the node number one which is hard-coded the default
+                       $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
+                       $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $nodeInstance->getRequestInstance()->getRequestElement('mode'));
+                       $searchInstance->setLimit(1);
+
+                       // Get a result back
+                       $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+                       // Set result instance in node instance
+                       $nodeInstance->setResultInstance($resultInstance);
+
+                       // Is it valid?
+                       $GLOBALS[__METHOD__] = $resultInstance->next();
+               } // END - if
+
+               // Return it
+               return $GLOBALS[__METHOD__];
+       }
+
        /**
         * 'Registers' a new node id along with data provided in the node instance.
         * This may sound confusing but avoids double code very nicely...