Cache of database "queries" can now be disabled (default). Please note, that if
[core.git] / inc / classes / main / database / class_BaseDatabaseWrapper.php
index 357be67706a1072528f2d63e4c2feb58cb84fb8c..9430c6ace7700cf68ec3bfe8a7484d725fcdf713 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A generic database wrapper
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.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
@@ -149,15 +149,15 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys);
 
                // Does this key exists in cache?
-               if ($this->cacheInstance->offsetExists($cacheKey)) {
+               if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
                        // Debug message
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey);
+                       /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE));
 
                        // Then use this result
                        $result = $this->cacheInstance->offsetGet($cacheKey);
                } else {
                        // Debug message
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->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);
@@ -176,7 +176,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                }
 
                // 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;