From 36dfe2c7247a1e6460826b41ce2cc011bb2d4ef9 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 16 Mar 2015 19:57:33 +0100 Subject: [PATCH] Renamed DatabaseResult to CachedDatabaseResult as it is actually "caching" the whole result. This means that the result is kept in array and this result can be used as an iterator to "walk" over the whole result. Later on if a non-cached version is coming the iteration will callback the backend for the actual iteration. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- inc/classes/main/class_BaseFrameworkSystem.php | 3 ++- inc/classes/main/database/class_BaseDatabaseWrapper.php | 3 ++- ...ss_DatabaseResult.php => class_CachedDatabaseResult.php} | 6 +++--- inc/config.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) rename inc/classes/main/result/{class_DatabaseResult.php => class_CachedDatabaseResult.php} (97%) diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 94769e12..7829b368 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -1894,7 +1894,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Do we have an entry? if ($this->getResultInstance()->valid() === FALSE) { - throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT); + // @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available + throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT); } // END - if // Get next entry diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php index 7653f4d2..77e530fd 100644 --- a/inc/classes/main/database/class_BaseDatabaseWrapper.php +++ b/inc/classes/main/database/class_BaseDatabaseWrapper.php @@ -194,7 +194,8 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { } } - // 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 diff --git a/inc/classes/main/result/class_DatabaseResult.php b/inc/classes/main/result/class_CachedDatabaseResult.php similarity index 97% rename from inc/classes/main/result/class_DatabaseResult.php rename to inc/classes/main/result/class_CachedDatabaseResult.php index 97bf28b4..b0076ffc 100644 --- a/inc/classes/main/result/class_DatabaseResult.php +++ b/inc/classes/main/result/class_CachedDatabaseResult.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, UpdateableResult, SeekableIterator { +class CachedDatabaseResult extends BaseFrameworkSystem implements SearchableResult, UpdateableResult, SeekableIterator { // Exception constants const EXCEPTION_INVALID_DATABASE_RESULT = 0x1c0; const EXCEPTION_RESULT_UPDATE_FAILED = 0x1c1; @@ -72,9 +72,9 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up * @param $resultArray The array holding the result from query * @return $resultInstance An instance of this class */ - public static final function createDatabaseResult (array $resultArray) { + public static final function createCachedDatabaseResult (array $resultArray) { // Get a new instance - $resultInstance = new DatabaseResult(); + $resultInstance = new CachedDatabaseResult(); // Set the result array $resultInstance->setResultArray($resultArray); diff --git a/inc/config.php b/inc/config.php index 900225cb..078542cc 100644 --- a/inc/config.php +++ b/inc/config.php @@ -171,7 +171,7 @@ $cfg->setConfigEntry('update_criteria_class', 'UpdateCriteria'); $cfg->setConfigEntry('file_io_class', 'FileIoHandler'); // CFG: DATABASE-RESULT-CLASS -$cfg->setConfigEntry('database_result_class', 'DatabaseResult'); +$cfg->setConfigEntry('database_result_class', 'CachedDatabaseResult'); // CFG: FILTER-CHAIN-CLASS $cfg->setConfigEntry('filter_chain_class', 'FilterChain'); -- 2.39.5