*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @return void
*/
private final function initCacheInstance () {
- // Set the new instance
- $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+ // Is the cache enabled?
+ if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) {
+ // Set the new instance
+ $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+ } // END - if
}
/**
// Cache the result if not null
if (!is_null($result)) {
- // A valid result has returned from the database layer
- $this->cacheInstance->offsetSet($cacheKey, $result);
+ // Is cache enabled?
+ if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) {
+ // A valid result has returned from the database layer
+ $this->cacheInstance->offsetSet($cacheKey, $result);
+ } // END - if
} else {
// This invalid result must be wrapped
$result = array(
}
}
- // Create an instance of a DatabaseResult class with the given result
+ // Create an instance of a CachedDatabaseResult class with the given result
+ // @TODO Minor: Update above comment to e.g. BaseDatabaseResult
$resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result));
// And return the instance
return $primaryKey;
}
+ /**
+ * Count rows of this table
+ *
+ * @return $count Count of total rows in this table
+ */
+ public final function countTotalRows () {
+ // Get the table name and a database instance and ask for it
+ $count = $this->getDatabaseInstance()->countTotalRows($this->getTableName());
+
+ // Return value
+ return $count;
+ }
+
/**
* Removes non-public data from given array.
*