Added some new stuff.
[core.git] / inc / classes / main / database / class_BaseDatabaseWrapper.php
index fde30c96ab9dddd9bf3e076ae0315f2ac10b25ca..c2a18b864e59f43df7d31fc98563e8469c75f1fc 100644 (file)
@@ -51,8 +51,11 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
         * @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
        }
 
        /**
@@ -183,8 +186,11 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
 
                        // 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(
@@ -242,6 +248,19 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                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.
         *