Rewrote the static call to dynamic
[core.git] / inc / classes / main / database / class_BaseDatabaseWrapper.php
index 4cdbafc019de11f7c3a4e4e9659c1bd0b6933b32..63d121c90af517c30ac50756b04071d1fee63c78 100644 (file)
@@ -84,7 +84,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
        protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) {
                // First get a key suitable for our cache and extend it with this class name
                $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
-               //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
 
                // Does this key exists in cache?
                if ($this->cacheInstance->offsetExists($cacheKey)) {
@@ -106,7 +106,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
        protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) {
                // First get a key suitable for our cache and extend it with this class name
                $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
-               //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
 
                // Does this key exists in cache?
                if ($this->cacheInstance->offsetExists($cacheKey)) {
@@ -127,6 +127,15 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                return $this->getDatabaseInstance()->getIndexKey();
        }
 
+       /**
+        * Getter for last exception
+        *
+        * @return      $lastException  Last exception or NULL if none occured
+        */
+       public final function getLastException () {
+               return $this->getDatabaseInstance()->getLastException();
+       }
+
        /**
         * Do a "select" query on the current table with the given search criteria and
         * store it in cache for later usage
@@ -142,13 +151,13 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                // Does this key exists in cache?
                if ($this->cacheInstance->offsetExists($cacheKey)) {
                        // Debug message
-                       //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey);
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey);
 
                        // Then use this result
                        $result = $this->cacheInstance->offsetGet($cacheKey);
                } else {
                        // Debug message
-                       //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
 
                        // Now it's time to ask the database layer for this select statement
                        $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
@@ -160,14 +169,14 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                        } else {
                                // This invalid result must be wrapped
                                $result = array(
-                                       BaseDatabaseFrontend::RESULT_INDEX_STATUS    => 'invalid',
-                                       BaseDatabaseFrontend::RESULT_INDEX_EXCEPTION => $this->getDatabaseInstance()->getLastException()
+                                       BaseDatabaseBackend::RESULT_INDEX_STATUS    => 'invalid',
+                                       BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => $this->getDatabaseInstance()->getLastException()
                                );
                        }
                }
 
                // Create an instance of a DatabaseResult class with the given result
-               $resultInstance = DatabaseResult::createDatabaseResult($result);
+               $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result));
 
                // And return the instance
                return $resultInstance;
@@ -193,7 +202,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                        $numRows = $resultInstance->getAffectedRows();
 
                        // Debug message
-                       //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
                } // END - if
 
                // Return the result