]> git.mxchange.org Git - core.git/commitdiff
Some 'static' array elements rewritten to constant, other cleanups
authorRoland Häder <roland@mxchange.org>
Thu, 1 Sep 2011 07:42:12 +0000 (07:42 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 1 Sep 2011 07:42:12 +0000 (07:42 +0000)
13 files changed:
inc/classes/interfaces/cache/class_Cacheable.php
inc/classes/main/cache/class_MemoryCache.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/criteria/class_BaseCriteria.php
inc/classes/main/criteria/dataset/class_DataSetCriteria.php
inc/classes/main/criteria/search/class_SearchCriteria.php
inc/classes/main/database/class_BaseDatabaseFrontend.php
inc/classes/main/database/class_BaseDatabaseWrapper.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php
inc/classes/main/filter/class_BaseFilterDecorator.php
inc/classes/main/result/class_DatabaseResult.php

index 6380f22ba29955ea7a2e9f7c5a40c8a250c9a729..4c9ee07721b5bfa22d8f528ba40a25d5e229cccb 100644 (file)
@@ -25,10 +25,35 @@ interface Cacheable extends FrameworkInterface {
        /**
         * Does the specified offset exist in cache?
         *
-        * @param       $offset         The offsrt we are looking for
+        * @param       $offset         The offset we are looking for
         * @return      $exists         Wether the offset exists
         */
-       function offsetExists ($offset);
+       function offsetExists($offset);
+
+       /**
+        * Setter for cache offset
+        *
+        * @param       $offset         The offset we shall set
+        * @param       $data           Data to store in cache
+        * @return      void
+        */
+       function offsetSet($offset, $data);
+
+       /**
+        * Getter for cache offset or "null" if not found
+        *
+        * @param       $offset         The offset we shall set
+        * @return      $data           Data to store in cache
+        */
+       function offsetGet($offset);
+
+       /**
+        * Purges the given cache entry
+        *
+        * @param       $offset         The offset we shall set
+        * @return      void
+        */
+       function purgeOffset($offset);
 }
 
 // [EOF]
index a38a65bab97d0290753aca47b9dd007021bc3e12..c3e24cc16f77fbf0878d404ca4b39c3cf03496f8 100644 (file)
@@ -69,7 +69,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
         * @param       $offset         The offset we are looking for
         * @return      $exists         Wether the offset exists
         */
-       public final function offsetExists ($offset) {
+       public function offsetExists ($offset) {
                $exists = $this->dataCache->offsetExists($offset);
                return $exists;
        }
@@ -81,7 +81,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
         * @param       $data           Data to store in cache
         * @return      void
         */
-       public final function offsetSet ($offset, $data) {
+       public function offsetSet ($offset, $data) {
                $this->dataCache->offsetSet($offset, $data);
        }
 
@@ -91,7 +91,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
         * @param       $offset         The offset we shall set
         * @return      $data           Data to store in cache
         */
-       public final function offsetGet ($offset) {
+       public function offsetGet ($offset) {
                // Default is offset not found
                $data = NULL;
 
@@ -99,11 +99,26 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
                if ($this->offsetExists($offset)) {
                        // Then get the data from it
                        $data = $this->dataCache->offsetGet($offset);
-               }
+               } // END - if
 
                // Return data
                return $data;
        }
+
+       /**
+        * Purges the given cache entry
+        *
+        * @param       $offset         The offset we shall set
+        * @return      void
+        */
+       public function purgeOffset ($offset) {
+               // Is the offset there?
+               if ($this->offsetExists($offset)) {
+                       // Purge only existing keys
+                       /* DEBUG: */ $this->debugOutput('CACHE: Unsetting cache ' . $offset);
+                       $this->dataCache->offsetUnset($offset);
+               } // END - if
+       }
 }
 
 // [EOF]
index f9474ca7567244eec20a7c39e415263c9b76507a..bdc442eee3ad0b3ea47207a2eed6ff01bf56ea44 100644 (file)
@@ -1897,6 +1897,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Return it
                return $responseType;
        }
+
+       /**
+        * Gets a cache key from Criteria instance
+        *
+        * @param       $criteriaInstance       An instance of a Criteria class
+        * @param       $onlyKeys                       Only use these keys for a cache key
+        * @return      $cacheKey                       A cache key suitable for lookup/storage purposes
+        */
+       protected function getCacheKeyByCriteria (Criteria $criteriaInstance, $onlyKeys = array()) {
+               // Generate it
+               $cacheKey = sprintf("%s@%s",
+                       $this->__toString(),
+                       $criteriaInstance->getCacheKey($onlyKeys)
+               );
+
+               // And return it
+               //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
+               return $cacheKey;
+       }
 }
 
 // [EOF]
index 5c94e1ebb4ced20491f37a898f335b337f545b09..4bec36a6f4efd99a4fa8bf3150b13459ab76cf2c 100644 (file)
@@ -27,6 +27,10 @@ class BaseCriteria extends BaseFrameworkSystem {
         */
        private $wrapperConfigEntry = '';
 
+       /**
+        * Criteria to handle
+        */
+       private $criteria = array();
        /**
         * Protected constructor
         *
@@ -56,6 +60,130 @@ class BaseCriteria extends BaseFrameworkSystem {
        public final function getWrapperConfigEntry () {
                return $this->wrapperConfigEntry;
        }
+
+       /**
+        * Getter for criteria array
+        *
+        * @return      $criteria
+        */
+       public final function getCriteriaArray () {
+               return $this->criteria;
+       }
+
+       /**
+        * Add criteria
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $criteriaValue  Criteria value
+        * @return      void
+        */
+       public final function addCriteria ($criteriaKey, $criteriaValue) {
+               $this->criteria[(string)$criteriaKey] = (string)$criteriaValue;
+       }
+
+       /**
+        * Add configured criteria
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $configEntry    Configuration entry
+        * @return      void
+        */
+       public final function addConfiguredCriteria ($criteriaKey, $configEntry) {
+               // Add the configuration entry as a criteria
+               $value = $this->getConfigInstance()->getConfigEntry($configEntry);
+               $this->addCriteria($criteriaKey, $value);
+       }
+
+       /**
+        * Get criteria element or null if not found
+        *
+        * @param       $criteria       The criteria we want to have
+        * @return      $value          Wether the value of the critera or null
+        */
+       public function getCriteriaElemnent ($criteria) {
+               // Default is not found
+               $value = NULL;
+
+               // Is the criteria there?
+               if (isset($this->criteria[$criteria])) {
+                       // Then use it
+                       $value = $this->criteria[$criteria];
+               }
+
+               // Return the value
+               return $value;
+       }
+
+       /**
+        * Checks wether given array entry matches
+        *
+        * @param       $entryArray             Array with the entries to find
+        * @return      $matches                Wether the entry matches or not
+        */
+       public function ifEntryMatches (array $entryArray) {
+               // First nothing matches and nothing is counted
+               $matches = false;
+               $counted = 0;
+
+               // Walk through all entries
+               foreach ($entryArray as $key => $entry) {
+                       // Then walk through all search criteria
+                       foreach ($this->criteria as $criteriaKey => $criteriaValue) {
+                               // Is the element found and does it match?
+                               if (($key == $criteriaKey) && ($criteriaValue == $entry)) {
+                                       // Then count this one up
+                                       $counted++;
+                               } // END - if
+                       } // END - foreach
+               } // END - foreach
+
+               // Now check if expected criteria counts match
+               $matches = ($counted == count($this->criteria));
+
+               // Return the result
+               return $matches;
+       }
+
+       /**
+        * "Getter" for a cache key
+        *
+        * @param       $onlyKeys       Only use these keys for a cache key
+        * @return      $cacheKey       The key suitable for the cache system
+        */
+       public function getCacheKey ($onlyKeys = array()) {
+               // Initialize the key
+               $cacheKey = '';
+
+               // Now walk through all criterias
+               foreach ($this->criteria as $criteriaKey => $criteriaValue) {
+                       // Is the value in array or is $onlyKeys empty?
+                       if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) {
+                               // Add the value URL encoded to avoid any trouble with special characters
+                               $cacheKey .= sprintf("%s=%s;",
+                                       $criteriaKey,
+                                       urlencode($criteriaValue)
+                               );
+                       } // END - if
+               } // END - foreach
+
+               // Remove last semicolon
+               $cacheKey = substr($cacheKey, 0, -1);
+
+               // Is the instance SearchCriteria?
+               if ($this instanceof SearchCriteria) {
+                       // Check if 'limit' and 'skip' are in
+                       if (((isset($onlyKeys['limit'])) && (isset($onlyKeys['skip']))) || (count($onlyKeys) == 0)) {
+                               // Add limit and skip values
+                               $cacheKey .= sprintf(";%%limit%%=%s;%%skip%%=%s",
+                                       $this->getLimit(),
+                                       $this->getSkip()
+                               );
+                       } // END - if
+               } // END - if
+
+               // Return the cache key
+               return $cacheKey;
+       }
 }
 
 // [EOF]
index cf4fdc96647fa0c20c9067d748cd903342541f5a..516f007ee417372d4c379624b08c86e60428a995 100644 (file)
@@ -28,11 +28,6 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
         */
        private $tableName = '';
 
-       /**
-        * Table columns (criteria) to store
-        */
-       private $tableColumns = array();
-
        /**
         * Unique key
         */
@@ -70,30 +65,6 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
                return $criteriaInstance;
        }
 
-       /**
-        * Add criteria
-        *
-        * @param       $criteriaKey    Criteria key
-        * @param       $criteriaValue  Criteria value
-        * @return      void
-        */
-       public function addCriteria ($criteriaKey, $criteriaValue) {
-               $this->tableColumns[(string) $criteriaKey] = $criteriaValue;
-       }
-
-       /**
-        * Add configured criteria
-        *
-        * @param       $criteriaKey    Criteria key
-        * @param       $configEntry    Configuration entry
-        * @return      void
-        */
-       public function addConfiguredCriteria ($criteriaKey, $configEntry) {
-               // Add configuration entry as criteria
-               $value = $this->getConfigInstance()->getConfigEntry($configEntry);
-               $this->addCriteria($criteriaKey, $value);
-       }
-
        /**
         * Setter for table name
         *
@@ -138,16 +109,7 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
         * @return      $uniqueValue    Value of the unique key
         */
        public final function getUniqueValue () {
-               return $this->tableColumns[$this->getUniqueKey()];
-       }
-
-       /**
-        * Getter for criteria array
-        *
-        * @return      $tableColumns
-        */
-       public final function getCriteriaArray () {
-               return $this->tableColumns;
+               return $this->getCriteriaElemnent($this->getUniqueKey());
        }
 
        /**
index 9692b713c297958586b0ac14090f9641b1abba37..eddc63e625a333c10ee0ddd07d7e5ded610ed127 100644 (file)
@@ -27,7 +27,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria {
        /**
         * Criteria to handle
         */
-       private $searchCriteria = array();
+       private $criteria = array();
 
        /**
         * Limitation for the search
@@ -62,30 +62,6 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria {
                return $criteriaInstance;
        }
 
-       /**
-        * Add criteria
-        *
-        * @param       $criteriaKey    Criteria key
-        * @param       $criteriaValue  Criteria value
-        * @return      void
-        */
-       public final function addCriteria ($criteriaKey, $criteriaValue) {
-               $this->searchCriteria[(string)$criteriaKey] = (string)$criteriaValue;
-       }
-
-       /**
-        * Add configured criteria
-        *
-        * @param       $criteriaKey    Criteria key
-        * @param       $configEntry    Configuration entry
-        * @return      void
-        */
-       public final function addConfiguredCriteria ($criteriaKey, $configEntry) {
-               // Add the configuration entry as a criteria
-               $value = $this->getConfigInstance()->getConfigEntry($configEntry);
-               $this->addCriteria($criteriaKey, $value);
-       }
-
        /**
         * Setter for limit
         *
@@ -137,84 +113,6 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria {
        public final function getSkip () {
                return $this->skip;
        }
-
-       /**
-        * "Getter" for a cache key
-        *
-        * @return      $cacheKey       The key suitable for the cache system
-        */
-       public function getCacheKey () {
-               // Initialize the key
-               $cacheKey = '';
-
-               // Now walk through all criterias
-               foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) {
-                       // Add the value URL encoded to avoid any trouble with special characters
-                       $cacheKey .= sprintf("%s=%s;",
-                               $criteriaKey,
-                               urlencode($criteriaValue)
-                       );
-               }
-
-               // Add limit and skip values
-               $cacheKey .= sprintf("%%limit%%=%s;%%skip%%=%s",
-                       $this->limit,
-                       $this->skip
-               );
-
-               // Return the cache key
-               return $cacheKey;
-       }
-
-       /**
-        * Get criteria element or null if not found
-        *
-        * @param       $criteria       The criteria we want to have
-        * @return      $value          Wether the value of the critera or null
-        */
-       public function getCriteriaElemnent ($criteria) {
-               // Default is not found
-               $value = NULL;
-
-               // Is the criteria there?
-               if (isset($this->searchCriteria[$criteria])) {
-                       // Then use it
-                       $value = $this->searchCriteria[$criteria];
-               }
-
-               // Return the value
-               return $value;
-       }
-
-       /**
-        * Checks wether given array entry matches
-        *
-        * @param       $entryArray             Array with the entries to find
-        * @return      $matches                Wether the entry matches or not
-        */
-       public function ifEntryMatches (array $entryArray) {
-               // First nothing matches and nothing is counted
-               $matches = false;
-               $counted = 0;
-
-               // Walk through all entries
-               foreach ($entryArray as $key => $entry) {
-                       // Then walk through all search criteria
-                       foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) {
-                               // Is the element found and does it match?
-                               if (($key == $criteriaKey) && ($criteriaValue == $entry)) {
-                                       // Then count this one up
-                                       $counted++;
-                               } // END - if
-                       } // END - foreach
-               } // END - foreach
-
-               // Now check if expected criteria counts match
-               $matches = ($counted == count($this->searchCriteria));
-
-               // Return the result
-               return $matches;
-       }
 }
 
 // [EOF]
index 2001a11fa054a30c206c75985f637dbc7394c231..40d563b4d4e89805d00140745d87d84e1d8c02df 100644 (file)
@@ -26,10 +26,10 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements Datab
        // Constants for exceptions
        const EXCEPTION_SQL_QUERY = 0x140;
 
-       /**
-        * The limiter instance
-        */
-       private $limitInstance = NULL;
+       // Result array indexes
+       const RESULT_INDEX_ROWS      = 'rows';
+       const RESULT_INDEX_STATUS    = 'status';
+       const RESULT_INDEX_EXCEPTION = 'exception';
 
        /**
         * Protected constructor
index 76d486e2df65d4f7a3e8cf57b1f30eeff024b73c..25b34774a5ecb696d6e10db4b59f5d68368f9429 100644 (file)
@@ -55,25 +55,92 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
        }
 
+       /**
+        * Setter for table name
+        *
+        * @param       $tableName      Name of table name to set
+        * @return      void
+        */
+       protected final function setTableName ($tableName) {
+               $this->tableName = (string) $tableName;
+       }
+
+       /**
+        * Getter for table name
+        *
+        * @return      $tableName      Name of table name to set
+        */
+       protected final function getTableName () {
+               return $this->tableName;
+       }
+
+       /**
+        * 'Inserts' a data set instance into a local file database folder
+        *
+        * @param       $dataSetInstance        A storeable data set
+        * @param       $onlyKeys                       Only use these keys for a cache key
+        * @return      void
+        */
+       protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, $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 ...');
+
+               // Does this key exists in cache?
+               if ($this->cacheInstance->offsetExists($cacheKey)) {
+                       // Purge the cache
+                       $this->cacheInstance->purgeOffset($cacheKey);
+               } // END - if
+
+               // Handle it over to the middleware
+               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+       }
+
+       /**
+        * 'Updates' a data set instance with a database layer
+        *
+        * @param       $dataSetInstance        A storeable data set
+        * @param       $onlyKeys                       Only use these keys for a cache key
+        * @return      void
+        */
+       protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, $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 ...');
+
+               // Does this key exists in cache?
+               if ($this->cacheInstance->offsetExists($cacheKey)) {
+                       // Purge the cache
+                       $this->cacheInstance->purgeOffset($cacheKey);
+               } // END - if
+
+               // Handle it over to the middleware
+               $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+       }
+
        /**
         * Do a "select" query on the current table with the given search criteria and
         * store it in cache for later usage
         *
         * @param       $criteriaInstance       An instance of a Criteria class
+        * @param       $onlyKeys                       Only use these keys for a cache key
         * @return      $resultInstance         An instance of a database result class
         */
-       public function doSelectByCriteria (Criteria $criteriaInstance) {
+       public function doSelectByCriteria (Criteria $criteriaInstance, $onlyKeys = array()) {
                // First get a key suitable for our cache and extend it with this class name
-               $cacheKey = sprintf("%s@%s",
-                       $this->__toString(),
-                       $criteriaInstance->getCacheKey()
-               );
+               $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys);
 
                // Does this key exists in cache?
                if ($this->cacheInstance->offsetExists($cacheKey)) {
+                       // Debug message
+                       //* DEBUG: */ $this->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);
+
                        // Now it's time to ask the database layer for this select statement
                        $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
 
@@ -84,8 +151,8 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                        } else {
                                // This invalid result must be wrapped
                                $result = array(
-                                       'status'                => 'invalid',
-                                       'exception'             => $this->getDatabaseInstance()->getLastException()
+                                       BaseDatabaseFrontend::RESULT_INDEX_STATUS    => 'invalid',
+                                       BaseDatabaseFrontend::RESULT_INDEX_EXCEPTION => $this->getDatabaseInstance()->getLastException()
                                );
                        }
                }
@@ -101,44 +168,29 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
         * Count the numbers of rows we shall receive
         *
         * @param       $criteriaInstance       An instance of a Criteria class
+        * @param       $onlyKeys                       Only use these keys for a cache key
         * @return      $numRows                        Numbers of rows of database entries
         */
-       public function doSelectCountByCriteria (Criteria $criteriaInstance) {
+       public function doSelectCountByCriteria (Criteria $criteriaInstance, $onlyKeys =  array()) {
                // Total numbers is -1 so we can distinglish between failed and valid queries
                $numRows = 0;
 
                // Get the result from above method
-               $resultInstance = $this->doSelectByCriteria($criteriaInstance);
+               $resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys);
 
                // Was that query fine?
                if ($resultInstance->ifStatusIsOkay()) {
                        // Then get the number of rows
                        $numRows = $resultInstance->getAffectedRows();
+
+                       // Debug message
+                       //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
                } // END - if
 
                // Return the result
                return $numRows;
        }
 
-       /**
-        * Setter for table name
-        *
-        * @param       $tableName      Name of table name to set
-        * @return      void
-        */
-       protected final function setTableName ($tableName) {
-               $this->tableName = (string) $tableName;
-       }
-
-       /**
-        * Getter for table name
-        *
-        * @return      $tableName      Name of table name to set
-        */
-       protected final function getTableName () {
-               return $this->tableName;
-       }
-
        /**
         * Getter for primary key used in wrapped table
         *
index 083729efdac4e3812565dae4bc7c5ca1acc88389..37dca8fcc4f2c3fa83c6e0a199b69db411a02477 100644 (file)
@@ -359,8 +359,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
 
                        // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read
                        $resultData = array(
-                               'status'        => LocalfileDatabase::RESULT_OKAY,
-                               'rows'          => array()
+                               BaseDatabaseFrontend::RESULT_INDEX_STATUS => LocalfileDatabase::RESULT_OKAY,
+                               BaseDatabaseFrontend::RESULT_INDEX_ROWS   => array()
                        );
 
                        // Initialize limit/skip
@@ -369,7 +369,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $idx = 1;
 
                        // Read the directory with some exceptions
-                       while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
+                       while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', 'info.' . $this->getFileExtension()))) && (($limitFound < $criteriaInstance->getLimit()) || ($criteriaInstance->getLimit() == 0))) {
                                // Does the extension match?
                                if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
                                        // Skip this file!
@@ -387,8 +387,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                                $criteria = $criteriaInstance->getCriteriaElemnent($key);
 
                                                // Is the criteria met?
+                                               //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: criteria[' . gettype($criteria) . ']=' . $criteria . ',()=' . strlen($criteria) . ',value=' . $value . ',()=' . strlen($value));
                                                if ((!is_null($criteria)) && ($criteria == $value))  {
-
                                                        // Shall we skip this entry?
                                                        if ($criteriaInstance->getSkip() > 0) {
                                                                // We shall skip some entries
@@ -403,7 +403,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                                        $dataArray[$this->getIndexKey()] = $idx;
 
                                                        // Entry found!
-                                                       $resultData['rows'][] = $dataArray;
+                                                       //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true));
+                                                       $resultData[BaseDatabaseFrontend::RESULT_INDEX_ROWS][] = $dataArray;
 
                                                        // Count found entries up
                                                        $limitFound++;
@@ -428,14 +429,14 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                } catch (PathIsNoDirectoryException $e) {
                        // Path not found means "table not found" for real databases...
                        $this->lastException = $e;
-                       $this->lastError = $e->getMessage();
+                       $this->lastError     = $e->getMessage();
 
                        // So throw an SqlException here with faked error message
                        throw new SqlException (array($this, sprintf("Table &#39;%s&#39; not found", $tableName), self::DB_CODE_TABLE_MISSING), self::EXCEPTION_SQL_QUERY);
                } catch (FrameworkException $e) {
                        // Catch all exceptions and store them in last error
                        $this->lastException = $e;
-                       $this->lastError = $e->getMessage();
+                       $this->lastError     = $e->getMessage();
                }
 
                // Return the gathered result
@@ -469,7 +470,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $this->lastError     = $e->getMessage();
 
                        // Throw an SQL exception
-                       throw new SqlException (array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
+                       throw new SqlException(array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
                }
        }
 
@@ -560,7 +561,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $this->lastError = $e->getMessage();
 
                        // Throw an SQL exception
-                       throw new SqlException (array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
+                       throw new SqlException(array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
                }
        }
 
index 557ab085dfcf104ac3c5b15feb265d019e6d6ae0..73e4c23af094393493e1c21c336fb70de0776257 100644 (file)
@@ -87,7 +87,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccou
                $registrationInstance->addElementsToDataSet($dataSetInstance);
 
                // "Insert" this request instance completely into the database
-               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+               $this->queryInsertDataSet($dataSetInstance);
        }
 
        /**
index f0cfb873cbc6ef36b402d3c51bdbf572d94ce77d..054a51b975083fa44cdae026144c08143fc2271c 100644 (file)
@@ -80,7 +80,7 @@ class UserPointsDatabaseWrapper extends BaseDatabaseWrapper implements BookableP
                $pointsInstance->addElementsToDataSet($dataSetInstance);
 
                // "Insert" this request instance completely into the database
-               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+               $this->queryInsertDataSet($dataSetInstance);
        }
 
        /**
index a3a23693254a8df84db8c60354361195c25ee5d3..338f0cb0f4537547e92318ccfde09c588b53ff70 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseFilterDecorator extends BaseFrameworkSystem implements Filterable {
+class BaseFilterDecorator extends BaseFrameworkSystem implements Filterable {
        /**
         * The decorated filter instance
         */
index e2505df0d50fd1000ccb5d1379fd5fd696c3ec02..0d3f8180dcb10e2275f373a1e7a78efbe710ee7b 100644 (file)
@@ -79,6 +79,9 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                // Set the result array
                $resultInstance->setResultArray($resultArray);
 
+               // Set affected rows
+               $resultInstance->setAffectedRows(count($resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS]));
+
                // Return the instance
                return $resultInstance;
        }
@@ -106,7 +109,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                // Now get the update criteria array and update all entries
                foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) {
                        // Update data
-                       $this->resultArray['rows'][$entryKey][$criteriaKey] = $criteriaValue;
+                       $this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS][$entryKey][$criteriaKey] = $criteriaValue;
 
                        // Mark it as out-dated
                        $this->outDated[$criteriaKey] = 1;
@@ -127,7 +130,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                if ($this->valid()) {
                        // Next entry found, so count one up and cache it
                        $this->currentPos++;
-                       $this->currentRow = $this->resultArray['rows'][$this->currentPos];
+                       $this->currentRow = $this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS][$this->currentPos];
                        $nextValid = true;
                } // END - if
 
@@ -162,9 +165,9 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                $current = NULL;
 
                // Does the current enty exist?
-               if (isset($this->resultArray['rows'][$this->currentPos])) {
+               if (isset($this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS][$this->currentPos])) {
                        // Then get it
-                       $current = $this->resultArray['rows'][$this->currentPos];
+                       $current = $this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS][$this->currentPos];
                } // END - if
 
                // Return the result
@@ -181,7 +184,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                $isValid = false;
 
                // Check if 
-               if (($this->ifStatusIsOkay()) && (isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) {
+               if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_ROWS][0]))) {
                        // All fine!
                        $isValid = true;
                } // END - if
@@ -196,7 +199,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
         * @return      $ifStatusOkay   Wether the status of the query was okay
         */
        public function ifStatusIsOkay () {
-               return ((isset($this->resultArray['status'])) && ($this->resultArray['status'] === LocalfileDatabase::RESULT_OKAY));
+               return ((isset($this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseFrontend::RESULT_INDEX_STATUS] === LocalfileDatabase::RESULT_OKAY));
        }
 
        /**
@@ -226,7 +229,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
         * @todo        0% done
         */
        public function searchEntry (LocalSearchCriteria $criteriaInstance) {
-               die(__METHOD__.": Unfinished!");
+               die(__METHOD__.': Unfinished!');
        }
 
        /**