$cfg->setConfigEntry('rng_class', 'Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator');
// CFG: USER-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('user_db_wrapper_class', 'Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper');
+$cfg->setConfigEntry('user_db_frontend_class', 'Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend');
// CFG: NEWS-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('news_db_wrapper_class', 'Org\Mxchange\CoreFramework\Database\Frontend\News\NewsDatabaseWrapper');
+$cfg->setConfigEntry('news_db_frontend_class', 'Org\Mxchange\CoreFramework\Database\Frontend\News\NewsDatabaseFrontend');
// CFG: HTML-CMD-RESOLVER-CLASS
$cfg->setConfigEntry('html_cmd_resolver_class', 'Org\Mxchange\CoreFramework\Resolver\Command\HtmlCommandResolver');
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Criteria\Criteria;
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
/**
* Self-referencing instance
*/
- private static $instance = NULL;
+ private static $selfInstance = NULL;
/**
* The real class name
*/
private $realClass = __CLASS__;
- /**
- * An instance of a database wrapper class
- */
- private $wrapperInstance = NULL;
-
/**
* State instance
*/
*/
public final function __call (string $methodName, array $args = NULL) {
// Set self-instance
- self::$instance = $this;
+ self::$selfInstance = $this;
// Call static method
self::__callStatic($methodName, $args);
// Clear self-instance
- self::$instance = NULL;
+ self::$selfInstance = NULL;
}
/**
* @param $methodName Name of the missing method
* @param $args Arguments passed to the method
* @return void
- * @throws InvalidArgumentException If self::$instance is not a framework's own object
+ * @throws InvalidArgumentException If self::$selfInstance is not a framework's own object
*/
public static final function __callStatic (string $methodName, array $args = NULL) {
// Init argument string and class name
$className = 'unknown';
// Is self-instance set?
- if (self::$instance instanceof FrameworkInterface) {
+ if (self::$selfInstance instanceof FrameworkInterface) {
// Framework's own instance
- $className = self::$instance->__toString();
- } elseif (!is_null(self::$instance)) {
+ $className = self::$selfInstance->__toString();
+ } elseif (!is_null(self::$selfInstance)) {
// Invalid argument!
- throw new InvalidArgumentException(sprintf('self::instance[%s] is not expected.', gettype(self::$instance)), self::EXCEPTION_SELF_INSTANCE);
+ throw new InvalidArgumentException(sprintf('self::instance[%s] is not expected.', gettype(self::$selfInstance)), self::EXCEPTION_SELF_INSTANCE);
}
// Is it NULL, empty or an array?
return $webOutputInstance;
}
- /**
- * Setter for DatabaseWrapper instance
- *
- * @param $wrapperInstance An instance of an DatabaseWrapper
- * @return void
- */
- public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) {
- $this->wrapperInstance = $wrapperInstance;
- }
-
- /**
- * Getter for DatabaseWrapper instance
- *
- * @return $wrapperInstance An instance of an DatabaseWrapper
- */
- public final function getWrapperInstance () {
- return $this->wrapperInstance;
- }
-
/**
* Setter for state instance
*
use Org\Mxchange\CoreFramework\Command\BaseCommand;
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
}
// Set username
- $this->getTemplateInstance()->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME));
+ $this->getTemplateInstance()->assignVariable('username', $userInstance->getField(UserDatabaseFrontend::DB_COLUMN_USERNAME));
// Construct the menu in every command. We could do this in BaseCommand class. But this means
// *every* command has a navigation system and that is want we don't want.
* @return void
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Default is no action
- $actionInstance = NULL;
-
// Get registry
$registryInstance = GenericRegistry::getRegistry();
use Org\Mxchange\CoreFramework\Command\BaseCommand;
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
$hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
// Update the user class
- $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
+ $userInstance->updateDatabaseField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH, $hashedString);
// Re-set config entry to mailer engine
FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('html_template_class', FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('mail_template_class'));
*/
abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria {
/**
- * Wrapper class name stored in config entry
+ * Frontend class name stored in config entry
*/
- private $wrapperConfigEntry = '';
+ private $frontendConfigEntry = '';
/**
* Protected constructor
}
/**
- * Setter for wrapper class name
+ * Setter for frontend class name
*
- * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name
+ * @param $frontendConfigEntry Configuration entry which hold the frontend class' name
* @return void
*/
- public final function setWrapperConfigEntry (string $wrapperConfigEntry) {
- $this->wrapperConfigEntry = $wrapperConfigEntry;
+ public final function setFrontendConfigEntry (string $frontendConfigEntry) {
+ $this->frontendConfigEntry = $frontendConfigEntry;
}
/**
- * Getter for wrapper class name
+ * Getter for frontend class name
*
- * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name
+ * @return $frontendConfigEntry Configuration entry which hold the frontend class' name
*/
- public final function getWrapperConfigEntry () {
- return $this->wrapperConfigEntry;
+ public final function getFrontendConfigEntry () {
+ return $this->frontendConfigEntry;
}
/**
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Backend;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
+use Org\Mxchange\CoreFramework\Generic\FrameworkException;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+
+/**
+ * An abstract database access class for handling database I/O requests
+ *
+ * @see DatabaseBackend - An interface for database backends
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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 BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend {
+ // Constants for exceptions
+ const EXCEPTION_SQL_QUERY = 0x140;
+
+ // Result array indexes
+ const RESULT_INDEX_ROWS = 'rows';
+ const RESULT_INDEX_STATUS = 'status';
+ const RESULT_INDEX_EXCEPTION = 'exception';
+
+ // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
+ const DB_CODE_TABLE_MISSING = 0x100;
+ const DB_CODE_TABLE_UNWRITEABLE = 0x101;
+ const DB_CODE_DATA_FILE_CORRUPT = 0x102;
+
+ // Status results
+ const RESULT_OKAY = 'ok';
+
+ /**
+ * Last thrown exception or NULL if all is fine
+ */
+ private $lastException = NULL;
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct (string $className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Getter for last exception
+ *
+ * @return $lastException Last thrown exception
+ */
+ public final function getLastException () {
+ return $this->lastException;
+ }
+
+ /**
+ * Setter for last exception
+ *
+ * @param $lastException Last thrown exception
+ * @return void
+ */
+ public final function setLastException (FrameworkException $exceptionInstance) {
+ $this->lastException = $exceptionInstance;
+ }
+
+ /**
+ * Reset the last exception instance. This should be done after a "query"
+ * was completed without any errors.
+ *
+ * @return void
+ */
+ protected final function resetLastException () {
+ $this->lastException = NULL;
+ }
+
+ /**
+ * Removes non-public data from given array.
+ *
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
+ */
+ public abstract function removeNonPublicDataFromArray (array $data);
+
+}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Backend;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
-use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-
-/**
- * An abstract database access class for handling database I/O requests
- *
- * @see DatabaseBackend - An interface for database backends
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend {
- // Constants for exceptions
- const EXCEPTION_SQL_QUERY = 0x140;
-
- // Result array indexes
- const RESULT_INDEX_ROWS = 'rows';
- const RESULT_INDEX_STATUS = 'status';
- const RESULT_INDEX_EXCEPTION = 'exception';
-
- // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
- const DB_CODE_TABLE_MISSING = 0x100;
- const DB_CODE_TABLE_UNWRITEABLE = 0x101;
- const DB_CODE_DATA_FILE_CORRUPT = 0x102;
-
- // Status results
- const RESULT_OKAY = 'ok';
-
- /**
- * Last thrown exception or NULL if all is fine
- */
- private $lastException = NULL;
-
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct (string $className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Getter for last exception
- *
- * @return $lastException Last thrown exception
- */
- public final function getLastException () {
- return $this->lastException;
- }
-
- /**
- * Setter for last exception
- *
- * @param $lastException Last thrown exception
- * @return void
- */
- public final function setLastException (FrameworkException $exceptionInstance) {
- $this->lastException = $exceptionInstance;
- }
-
- /**
- * Reset the last exception instance. This should be done after a "query"
- * was completed without any errors.
- *
- * @return void
- */
- protected final function resetLastException () {
- $this->lastException = NULL;
- }
-
- /**
- * Removes non-public data from given array.
- *
- * @param $data An array with possible non-public data that needs to be removed.
- * @return $data A cleaned up array with only public data.
- */
- public abstract function removeNonPublicDataFromArray (array $data);
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Criteria\Criteria;
-use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-
-/**
- * A generic database wrapper
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 BaseDatabaseWrapper extends BaseFrameworkSystem {
- /**
- * Cache instance
- */
- private $cacheInstance = NULL;
-
- /**
- * Current table name to use
- */
- private $tableName = 'unknown';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct ($class) {
- // Call parent constructor
- parent::__construct($class);
-
- // Initialize the cache instance
- $this->initCacheInstance();
- }
-
- /**
- * Initializes the cache instance with a new object
- *
- * @return void
- */
- private final function initCacheInstance () {
- // Is the cache enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
- // Set the new instance
- $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
- } // END - if
- }
-
- /**
- * 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, array $onlyKeys = []) {
- // Default cache key is NULL
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys)));
- $cacheKey = NULL;
-
- // Is cache enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
- // First get a key suitable for our cache and extend it with this class name
- $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
- } // END - if
-
- // Does this key exists in cache?
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
- if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
- // Purge the cache
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey));
- $this->cacheInstance->purgeOffset($cacheKey);
- } // END - if
-
- // Handle it over to the middleware
- FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
-
- // Trace message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: EXIT!');
- }
-
- /**
- * '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, array $onlyKeys = []) {
- // Init cache key
- $cacheKey = NULL;
-
- // Is cache enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
- // First get a key suitable for our cache and extend it with this class name
- $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
- } // END - if
-
- // Does this key exists in cache?
- if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
- // Purge the cache
- $this->cacheInstance->purgeOffset($cacheKey);
- } // END - if
-
- // Handle it over to the middleware
- FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
- }
-
- /**
- * Getter for index key
- *
- * @return $indexKey Index key
- */
- public final function getIndexKey () {
- return FrameworkBootstrap::getDatabaseInstance()->getIndexKey();
- }
-
- /**
- * Getter for last exception
- *
- * @return $lastException Last exception or NULL if none occured
- */
- public final function getLastException () {
- return FrameworkBootstrap::getDatabaseInstance()->getLastException();
- }
-
- /**
- * 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, array $onlyKeys = []) {
- // Default cache key if cache is not enabled
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys)));
- $cacheKey = NULL;
- $result = [];
-
- // Is the cache enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
- // First get a key suitable for our cache and extend it with this class name
- $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys);
- } // END - if
-
- // Does this key exists in cache?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
- if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
- // Then use this result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Cache used for cacheKey=%s', $cacheKey));
- $result = $this->cacheInstance->offsetGet($cacheKey);
- } else {
- // Now it's time to ask the database layer for this select statement
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Quering database, cacheKey=%s ...', $cacheKey));
- $result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
-
- // Cache the result if not null
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[]=%s', gettype($result)));
- if (!is_null($result)) {
- // Is cache enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
- // A valid result has returned from the database layer
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result)));
- $this->cacheInstance->offsetSet($cacheKey, $result);
- } // END - if
- } else {
- // This invalid result must be wrapped
- $result = array(
- BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid',
- BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException()
- );
- }
- }
-
- // Create an instance of a CachedDatabaseResult class with the given result
- // @TODO Minor: Update above comment to e.g. BaseDatabaseResult
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseBackend::RESULT_INDEX_STATUS, $result[BaseDatabaseBackend::RESULT_INDEX_STATUS], BaseDatabaseBackend::RESULT_INDEX_ROWS, isset($result[BaseDatabaseBackend::RESULT_INDEX_ROWS]), BaseDatabaseBackend::RESULT_INDEX_EXCEPTION, isset($result[BaseDatabaseBackend::RESULT_INDEX_EXCEPTION])));
- $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result));
-
- // And return the instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: resultInstance=%s - EXIT!', $resultInstance->__toString()));
- return $resultInstance;
- }
-
- /**
- * 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, array $onlyKeys = []) {
- // 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, $onlyKeys);
-
- // Was that query fine?
- if ($resultInstance->ifStatusIsOkay()) {
- // Then get the number of rows
- $numRows = $resultInstance->getAffectedRows();
-
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
- } // END - if
-
- // Return the result
- return $numRows;
- }
-
- /**
- * Getter for primary key used in wrapped table
- *
- * @return $primaryKey Primary key used in wrapped table
- */
- public final function getPrimaryKeyValue () {
- // Get the table name and a database instance and ask for it
- $primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName());
-
- // Return value
- 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 = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName());
-
- // Return value
- return $count;
- }
-
- /**
- * Removes non-public data from given array.
- *
- * @param $data An array with possible non-public data that needs to be removed.
- * @return $data A cleaned up array with only public data.
- */
- public function removeNonPublicDataFromArray (array $data) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray(data) ...');
- $data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data);
-
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data));
- return $data;
- }
-
-}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Criteria\Criteria;
+use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
+use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+
+/**
+ * A generic database frontend
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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 BaseDatabaseFrontend extends BaseFrameworkSystem {
+ /**
+ * Cache instance
+ */
+ private $cacheInstance = NULL;
+
+ /**
+ * Current table name to use
+ */
+ private $tableName = 'unknown';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct ($class) {
+ // Call parent constructor
+ parent::__construct($class);
+
+ // Initialize the cache instance
+ $this->initCacheInstance();
+ }
+
+ /**
+ * Initializes the cache instance with a new object
+ *
+ * @return void
+ */
+ private final function initCacheInstance () {
+ // Is the cache enabled?
+ if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
+ // Set the new instance
+ $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+ } // END - if
+ }
+
+ /**
+ * 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, array $onlyKeys = []) {
+ // Default cache key is NULL
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys)));
+ $cacheKey = NULL;
+
+ // Is cache enabled?
+ if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
+ // First get a key suitable for our cache and extend it with this class name
+ $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+ } // END - if
+
+ // Does this key exists in cache?
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
+ if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
+ // Purge the cache
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey));
+ $this->cacheInstance->purgeOffset($cacheKey);
+ } // END - if
+
+ // Handle it over to the middleware
+ FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+
+ // Trace message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: EXIT!');
+ }
+
+ /**
+ * '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, array $onlyKeys = []) {
+ // Init cache key
+ $cacheKey = NULL;
+
+ // Is cache enabled?
+ if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
+ // First get a key suitable for our cache and extend it with this class name
+ $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+ } // END - if
+
+ // Does this key exists in cache?
+ if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
+ // Purge the cache
+ $this->cacheInstance->purgeOffset($cacheKey);
+ } // END - if
+
+ // Handle it over to the middleware
+ FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+ }
+
+ /**
+ * Getter for index key
+ *
+ * @return $indexKey Index key
+ */
+ public final function getIndexKey () {
+ return FrameworkBootstrap::getDatabaseInstance()->getIndexKey();
+ }
+
+ /**
+ * Getter for last exception
+ *
+ * @return $lastException Last exception or NULL if none occured
+ */
+ public final function getLastException () {
+ return FrameworkBootstrap::getDatabaseInstance()->getLastException();
+ }
+
+ /**
+ * 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, array $onlyKeys = []) {
+ // Default cache key if cache is not enabled
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys)));
+ $cacheKey = NULL;
+ $result = [];
+
+ // Is the cache enabled?
+ if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
+ // First get a key suitable for our cache and extend it with this class name
+ $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys);
+ } // END - if
+
+ // Does this key exists in cache?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
+ if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
+ // Then use this result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Cache used for cacheKey=%s', $cacheKey));
+ $result = $this->cacheInstance->offsetGet($cacheKey);
+ } else {
+ // Now it's time to ask the database layer for this select statement
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Quering database, cacheKey=%s ...', $cacheKey));
+ $result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
+
+ // Cache the result if not null
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[]=%s', gettype($result)));
+ if (!is_null($result)) {
+ // Is cache enabled?
+ if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
+ // A valid result has returned from the database layer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result)));
+ $this->cacheInstance->offsetSet($cacheKey, $result);
+ } // END - if
+ } else {
+ // This invalid result must be wrapped
+ $result = array(
+ BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid',
+ BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException()
+ );
+ }
+ }
+
+ // Create an instance of a CachedDatabaseResult class with the given result
+ // @TODO Minor: Update above comment to e.g. BaseDatabaseResult
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseBackend::RESULT_INDEX_STATUS, $result[BaseDatabaseBackend::RESULT_INDEX_STATUS], BaseDatabaseBackend::RESULT_INDEX_ROWS, isset($result[BaseDatabaseBackend::RESULT_INDEX_ROWS]), BaseDatabaseBackend::RESULT_INDEX_EXCEPTION, isset($result[BaseDatabaseBackend::RESULT_INDEX_EXCEPTION])));
+ $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result));
+
+ // And return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: resultInstance=%s - EXIT!', $resultInstance->__toString()));
+ return $resultInstance;
+ }
+
+ /**
+ * 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, array $onlyKeys = []) {
+ // 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, $onlyKeys);
+
+ // Was that query fine?
+ if ($resultInstance->ifStatusIsOkay()) {
+ // Then get the number of rows
+ $numRows = $resultInstance->getAffectedRows();
+
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows);
+ } // END - if
+
+ // Return the result
+ return $numRows;
+ }
+
+ /**
+ * Getter for primary key used in wrapped table
+ *
+ * @return $primaryKey Primary key used in wrapped table
+ */
+ public final function getPrimaryKeyValue () {
+ // Get the table name and a database instance and ask for it
+ $primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName());
+
+ // Return value
+ 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 = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName());
+
+ // Return value
+ return $count;
+ }
+
+ /**
+ * Removes non-public data from given array.
+ *
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
+ */
+ public function removeNonPublicDataFromArray (array $data) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray(data) ...');
+ $data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data);
+
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data));
+ return $data;
+ }
+
+}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend\News;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseWrapper;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-
-/**
- * A database wrapper for news classes
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- * @todo Add missing own interface for public methods
- *
- * 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class NewsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable {
- // Constants for database table names
- const DB_TABLE_NEWS = 'news';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createNewsDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new NewsDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_NEWS);
-
- // Return the instance
- return $wrapperInstance;
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseWrapper;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-
-/**
- * A database wrapper for payments
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- * @todo Add missing own interface for public methods
- *
- * 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class PaymentsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable {
- // Constants for exceptions
- const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
-
- // Constants for database table names
- const DB_TABLE_PAYMENTS = 'payments';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createPaymentsDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new PaymentsDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_PAYMENTS);
-
- // Return the instance
- return $wrapperInstance;
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend\User;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseWrapper;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Generic\NullPointerException;
-use Org\Mxchange\CoreFramework\Registration\User\UserRegister;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
-use Org\Mxchange\CoreFramework\Wrapper\Account\ManageableAccountWrapper;
-
-/**
- * A database wrapper for the User class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccountWrapper, Registerable {
- // Constants for exceptions
- const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
-
- // Constants for database columns
- const DB_COLUMN_USERID = 'userid';
- const DB_COLUMN_USERNAME = 'username';
- const DB_COLUMN_EMAIL = 'email';
- const DB_COLUMN_CONFIRM_HASH = 'confirm_hash';
- const DB_COLUMN_USER_STATUS = 'user_status';
-
- // Constants for database table names
- const DB_TABLE_USER = 'user';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createUserDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new UserDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_USER);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Handles inserting the registration data from a registration instance into the database
- *
- * @param $registrationInstance An instance of a registration class
- * @return void
- */
- public function insertRegistrationObject (UserRegister $registrationInstance) {
- // Generate a data set for the request
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER));
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME);
-
- // Add registration elements to the dataset
- $registrationInstance->addElementsToDataSet($dataSetInstance);
-
- // "Insert" this request instance completely into the database
- $this->queryInsertDataSet($dataSetInstance);
- }
-
- /**
- * Updates an user database entry with given result
- *
- * @param $resultInstance An instance of a UpdateableResult class
- * @return void
- * @throws NullPointerException If $updateInstance or $searchInstance is null
- */
- public function doUpdateByResult (UpdateableResult $resultInstance) {
- // Get the search instance from result
- $searchInstance = $resultInstance->getSearchInstance();
-
- // Is this null?
- if (is_null($searchInstance)) {
- // Get the update instance
- $updateInstance = $resultInstance->getUpdateInstance();
-
- // Is this null?
- if (is_null($updateInstance)) {
- // Throw an exception here
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
-
- // Get search instance from update instance
- $searchInstance = $updateInstance->getSearchInstance();
-
- // Is it still null?
- if (is_null($searchInstance)) {
- // Throw an exception here
- throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
- } // END - if
-
- // Generate a data set object
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER));
-
- // Add seach criteria
- $dataSetInstance->setSearchInstance($searchInstance);
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME);
-
- // Add all update criteria to the database set
- $resultInstance->addElementsToDataSet($dataSetInstance);
-
- // "Update" this request with the database
- FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend\Points;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseWrapper;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
-
-/**
- * A database wrapper for user points classes
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class UserPointsDatabaseWrapper extends BaseDatabaseWrapper implements BookablePointsWrapper, Registerable {
- /**
- * Constants for database table names
- */
- const DB_TABLE_USER_POINTS = 'user_points';
-
- /**
- * Name of the user->points column
- */
- const DB_COLUMN_POINTS_UID = 'points_uid';
-
- /**
- * Name of the points column
- */
- const DB_COLUMN_POINTS = 'points';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this database wrapper by a provided user class
- *
- * @return $wrapperInstance An instance of the created wrapper class
- */
- public static final function createUserPointsDatabaseWrapper () {
- // Get a new instance
- $wrapperInstance = new UserPointsDatabaseWrapper();
-
- // Set (primary!) table name
- $wrapperInstance->setTableName(self::DB_TABLE_USER_POINTS);
-
- // Return the instance
- return $wrapperInstance;
- }
-
- /**
- * Inserts the given points for the given user in the database
- *
- * @param $pointsInstance An instance of a user class
- * @return void
- */
- public function insertUserPoints (BookablePoints $pointsInstance) {
- // Generate a data set for the request
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS));
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID);
-
- // Add registration elements to the dataset
- $pointsInstance->addElementsToDataSet($dataSetInstance);
-
- // "Insert" this request instance completely into the database
- $this->queryInsertDataSet($dataSetInstance);
- }
-
- /**
- * Updates an user database entry with given result
- *
- * @param $resultInstance An instance of a UpdateableResult class
- * @return void
- */
- public function doUpdateByResult (UpdateableResult $resultInstance) {
- // Generate a data set object
- $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS));
-
- // Add all update criteria to the database set
- $resultInstance->addElementsToDataSet($dataSetInstance);
-
- // Add seach criteria
- $dataSetInstance->setSearchInstance($resultInstance->getUpdateInstance()->getSearchInstance());
-
- // Set the primary key
- $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID);
-
- // "Update" this request with the database
- FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
- }
-
-}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend\News;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseFrontend;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+/**
+ * A database frontend for news classes
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ * @todo Add missing own interface for public methods
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class NewsDatabaseFrontend extends BaseDatabaseFrontend implements Registerable {
+ // Constants for database table names
+ const DB_TABLE_NEWS = 'news';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database frontend by a provided user class
+ *
+ * @return $frontendInstance An instance of the created frontend class
+ */
+ public static final function createNewsDatabaseFrontend () {
+ // Get a new instance
+ $frontendInstance = new NewsDatabaseFrontend();
+
+ // Set (primary!) table name
+ $frontendInstance->setTableName(self::DB_TABLE_NEWS);
+
+ // Return the instance
+ return $frontendInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseFrontend;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+/**
+ * A database frontend for payments
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ * @todo Add missing own interface for public methods
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class PaymentsDatabaseFrontend extends BaseDatabaseFrontend implements Registerable {
+ // Constants for exceptions
+ const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
+
+ // Constants for database table names
+ const DB_TABLE_PAYMENTS = 'payments';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database frontend by a provided user class
+ *
+ * @return $frontendInstance An instance of the created frontend class
+ */
+ public static final function createPaymentsDatabaseFrontend () {
+ // Get a new instance
+ $frontendInstance = new PaymentsDatabaseFrontend();
+
+ // Set (primary!) table name
+ $frontendInstance->setTableName(self::DB_TABLE_PAYMENTS);
+
+ // Return the instance
+ return $frontendInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend\User;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseFrontend;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Frontend\Account\ManageableAccountFrontend;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Registration\User\UserRegister;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
+
+/**
+ * A database frontend for the User class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UserDatabaseFrontend extends BaseDatabaseFrontend implements ManageableAccountFrontend, Registerable {
+ // Constants for exceptions
+ const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
+
+ // Constants for database columns
+ const DB_COLUMN_USERID = 'userid';
+ const DB_COLUMN_USERNAME = 'username';
+ const DB_COLUMN_EMAIL = 'email';
+ const DB_COLUMN_CONFIRM_HASH = 'confirm_hash';
+ const DB_COLUMN_USER_STATUS = 'user_status';
+
+ // Constants for database table names
+ const DB_TABLE_USER = 'user';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database frontend by a provided user class
+ *
+ * @return $frontendInstance An instance of the created frontend class
+ */
+ public static final function createUserDatabaseFrontend () {
+ // Get a new instance
+ $frontendInstance = new UserDatabaseFrontend();
+
+ // Set (primary!) table name
+ $frontendInstance->setTableName(self::DB_TABLE_USER);
+
+ // Return the instance
+ return $frontendInstance;
+ }
+
+ /**
+ * Handles inserting the registration data from a registration instance into the database
+ *
+ * @param $registrationInstance An instance of a registration class
+ * @return void
+ */
+ public function insertRegistrationObject (UserRegister $registrationInstance) {
+ // Generate a data set for the request
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME);
+
+ // Add registration elements to the dataset
+ $registrationInstance->addElementsToDataSet($dataSetInstance);
+
+ // "Insert" this request instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+ }
+
+ /**
+ * Updates an user database entry with given result
+ *
+ * @param $resultInstance An instance of a UpdateableResult class
+ * @return void
+ * @throws NullPointerException If $updateInstance or $searchInstance is null
+ */
+ public function doUpdateByResult (UpdateableResult $resultInstance) {
+ // Get the search instance from result
+ $searchInstance = $resultInstance->getSearchInstance();
+
+ // Is this null?
+ if (is_null($searchInstance)) {
+ // Get the update instance
+ $updateInstance = $resultInstance->getUpdateInstance();
+
+ // Is this null?
+ if (is_null($updateInstance)) {
+ // Throw an exception here
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+
+ // Get search instance from update instance
+ $searchInstance = $updateInstance->getSearchInstance();
+
+ // Is it still null?
+ if (is_null($searchInstance)) {
+ // Throw an exception here
+ throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+ } // END - if
+
+ // Generate a data set object
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER));
+
+ // Add seach criteria
+ $dataSetInstance->setSearchInstance($searchInstance);
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME);
+
+ // Add all update criteria to the database set
+ $resultInstance->addElementsToDataSet($dataSetInstance);
+
+ // "Update" this request with the database
+ FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend\Points;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseFrontend;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
+
+/**
+ * A database frontend for user points classes
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UserPointsDatabaseFrontend extends BaseDatabaseFrontend implements BookablePointsFrontend, Registerable {
+ /**
+ * Constants for database table names
+ */
+ const DB_TABLE_USER_POINTS = 'user_points';
+
+ /**
+ * Name of the user->points column
+ */
+ const DB_COLUMN_POINTS_UID = 'points_uid';
+
+ /**
+ * Name of the points column
+ */
+ const DB_COLUMN_POINTS = 'points';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database frontend by a provided user class
+ *
+ * @return $frontendInstance An instance of the created frontend class
+ */
+ public static final function createUserPointsDatabaseFrontend () {
+ // Get a new instance
+ $frontendInstance = new UserPointsDatabaseFrontend();
+
+ // Set (primary!) table name
+ $frontendInstance->setTableName(self::DB_TABLE_USER_POINTS);
+
+ // Return the instance
+ return $frontendInstance;
+ }
+
+ /**
+ * Inserts the given points for the given user in the database
+ *
+ * @param $pointsInstance An instance of a user class
+ * @return void
+ */
+ public function insertUserPoints (BookablePoints $pointsInstance) {
+ // Generate a data set for the request
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS));
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID);
+
+ // Add registration elements to the dataset
+ $pointsInstance->addElementsToDataSet($dataSetInstance);
+
+ // "Insert" this request instance completely into the database
+ $this->queryInsertDataSet($dataSetInstance);
+ }
+
+ /**
+ * Updates an user database entry with given result
+ *
+ * @param $resultInstance An instance of a UpdateableResult class
+ * @return void
+ */
+ public function doUpdateByResult (UpdateableResult $resultInstance) {
+ // Generate a data set object
+ $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS));
+
+ // Add all update criteria to the database set
+ $resultInstance->addElementsToDataSet($dataSetInstance);
+
+ // Add seach criteria
+ $dataSetInstance->setSearchInstance($resultInstance->getUpdateInstance()->getSearchInstance());
+
+ // Set the primary key
+ $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID);
+
+ // "Update" this request with the database
+ FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+ }
+
+}
use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
* Solver for result index value with call-back method
*
* @param $databaseColumn Database column where the index might be found
- * @param $wrapperInstance The wrapper instance to ask for array element
+ * @param $frontendInstance The frontend instance to ask for array element
* @para $callBack Call-back object for setting the index;
* 0=object instance,1=method name
* @return void
* @todo Find a caching way without modifying the result array
*/
- public function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack) {
+ public function solveResultIndex ($databaseColumn, DatabaseFrontend $frontendInstance, array $callBack) {
// By default nothing is found
$indexValue = 0;
if ($this->find($databaseColumn)) {
// Use this value
$indexValue = $this->getFoundValue();
- } elseif ($this->find($wrapperInstance->getIndexKey())) {
+ } elseif ($this->find($frontendInstance->getIndexKey())) {
// Use this value
$indexValue = $this->getFoundValue();
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Discovery\BaseDiscovery;
use Org\Mxchange\CoreFramework\Discovery\Discoverable;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filter\Filterable;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
$criteriaInstance->addCriteria('payment_action', $this->getActionName() . '_action');
$criteriaInstance->setLimit(1);
- // Get a wrapper instance
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('payment_db_wrapper_class');
+ // Get a frontend instance
+ $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('payment_db_frontend_class');
// Get result back
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance);
// Advanced to next entry and assert on it as it should always be there
assert($resultInstance->valid());
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Factory\Database\Frontend;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+
+/**
+ * A factory class for socket registries
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class DatabaseFrontendFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton socket registry instance. If an instance is found in
+ * the registry it will be returned, else a new instance is created and
+ * stored in the same registry entry.
+ *
+ * @return $frontendInstance A database frontend instance
+ */
+ public static final function createFrontendByConfiguredName ($frontendName) {
+ // Get registry instance
+ $registryInstance = GenericRegistry::getRegistry();
+
+ // Do we have an instance in the registry?
+ if ($registryInstance->instanceExists($frontendName)) {
+ // Then use this instance
+ $frontendInstance = $registryInstance->getInstance($frontendName);
+ } else {
+ // Get the registry instance
+ $frontendInstance = self::createObjectByConfiguredName($frontendName);
+
+ // Set the instance in registry for further use
+ $registryInstance->addInstance($frontendName, $frontendInstance);
+ }
+
+ // Return the instance
+ return $frontendInstance;
+ }
+
+}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Factory\Database\Wrapper;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
-
-/**
- * A factory class for socket registries
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class DatabaseWrapperFactory extends ObjectFactory {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Returns a singleton socket registry instance. If an instance is found in
- * the registry it will be returned, else a new instance is created and
- * stored in the same registry entry.
- *
- * @return $wrapperInstance A database wrapper instance
- */
- public static final function createWrapperByConfiguredName ($wrapperName) {
- // Get registry instance
- $registryInstance = GenericRegistry::getRegistry();
-
- // Do we have an instance in the registry?
- if ($registryInstance->instanceExists($wrapperName)) {
- // Then use this instance
- $wrapperInstance = $registryInstance->getInstance($wrapperName);
- } else {
- // Get the registry instance
- $wrapperInstance = self::createObjectByConfiguredName($wrapperName);
-
- // Set the instance in registry for further use
- $registryInstance->addInstance($wrapperName, $wrapperInstance);
- }
-
- // Return the instance
- return $wrapperInstance;
- }
-
-}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
$confirmed = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed');
// Update the user status to "confirmed" here
- $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $confirmed);
+ $userInstance->updateDatabaseField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS, $confirmed);
// Wipe out the confirm hash for extra security
- $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, '');
+ $userInstance->updateDatabaseField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH, '');
// Write all updates to the database
die(__METHOD__ . ': REWRITE!' . PHP_EOL);
namespace Org\Mxchange\CoreFramework\Filter\Verifier\Confirmation;
// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
$userInstance = GenericRegistry::getRegistry()->getInstance('user');
// Get the confirm code from user for comparison
- $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH);
+ $userCode = $userInstance->getField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH);
// Do we have the same code or different?
if ($userCode != $confirmCode) {
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\User\UserFactory;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
} // END - if
// Is the user account confirmed?
- if ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')) {
+ if ($userInstance->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')) {
// Request is invalid!
$requestInstance->requestIsValid(false);
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\Wrapper\Fuse;
+namespace Org\Mxchange\CoreFramework\Frontend\Fuse;
// Import framework stuff
use Org\Mxchange\CoreFramework\Registry\Registerable;
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
* @return $isUnconfirmed Whether the user account is unconfirmed
*/
public function ifUserAccountUnconfirmed () {
- $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed'));
+ $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed'));
return $isUnconfirmed;
}
* @return $isUnconfirmed Whether the user account is locked
*/
public function ifUserAccountLocked () {
- $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked'));
+ $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked'));
return $isUnconfirmed;
}
* @return $isUnconfirmed Whether the user account is a guest
*/
public function ifUserAccountGuest () {
- $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
+ $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
return $isUnconfirmed;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\Registerable;
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add search criteria
- $searchInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $userInstance->getUserId());
+ $searchInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS_UID, $userInstance->getUserId());
$searchInstance->setLimit(1);
- // Get a wrapper instance
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('user_points_db_wrapper_class');
+ // Get a frontend instance
+ $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('user_points_db_frontend_class');
// Get result back
- $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($searchInstance);
// Advance to first entry by default
$resultInstance->next();
$currentEntry = $this->getResultInstance()->current();
// Add the points
- $amount += $currentEntry[UserPointsDatabaseWrapper::DB_COLUMN_POINTS];
+ $amount += $currentEntry[UserPointsDatabaseFrontend::DB_COLUMN_POINTS];
// Now get another criteria
$updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
// And add our both entries
- $updateInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $amount);
+ $updateInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS, $amount);
// Add the search criteria for searching for the right entry
$updateInstance->setSearchInstance($searchInstance);
- // Set wrapper class name
- $updateInstance->setWrapperConfigEntry('user_points_db_wrapper_class');
+ // Set frontend class name
+ $updateInstance->setFrontendConfigEntry('user_points_db_frontend_class');
// Remember the update in database result
$this->getResultInstance()->add2UpdateQueue($updateInstance);
$this->setAmount($amount);
// Create the new entry
- $wrapperInstance->insertUserPoints($this);
+ $frontendInstance->insertUserPoints($this);
}
}
*/
public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
// Add user id
- $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId());
+ $criteriaInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId());
// Add amount
- $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $this->getAmount());
+ $criteriaInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS, $this->getAmount());
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Reader\News\ReadableNews;
// Get 'command' for saving some calls
$command = FrameworkBootstrap::getRequestInstance()->getRequestElement('command');
- // First get a wrapper instance
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class');
+ // First get a frontend instance
+ $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('news_db_frontend_class');
// Next create a searchable criteria instance
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
$criteriaInstance->setConfiguredLimit('news_' . $command . '_limit');
// Get a resultInstance back from the database
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance);
// Save that resultInstance in this class
$this->setResultInstance($resultInstance);
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\Registerable;
// Get 'command' for saving some calls
$command = FrameworkBootstrap::getRequestInstance()->getRequestElement('command');
- // First get a wrapper instance
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class');
+ // First get a frontend instance
+ $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('news_db_frontend_class');
// Next create a searchable criteria instance
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
$criteriaInstance->setConfiguredLimit('news_' . $command . '_limit');
// Get a resultInstance back from the database
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance);
// Save that resultInstance in this class
$this->setResultInstance($resultInstance);
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Database\Updateable;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Is a previous result there?
if (!$this->getResultInstance() instanceof SearchableResult) {
- // Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+ // Get a UserDatabaseFrontend instance
+ $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class');
// Create a search criteria
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $criteriaInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName());
$criteriaInstance->setLimit(1);
// Get a search result
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance);
// Set the index "solver"
- $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+ $resultInstance->solveResultIndex(UserDatabaseFrontend::DB_COLUMN_USERID, $frontendInstance, array($this, 'setUserId'));
// And finally set it
$this->setResultInstance($resultInstance);
// Is a previous result there?
if (!$this->getResultInstance() instanceof SearchableResult) {
- // Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+ // Get a UserDatabaseFrontend instance
+ $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class');
// Create a search criteria
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
+ $criteriaInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_EMAIL, $this->getEmail());
$criteriaInstance->setLimit(1);
// Get a search result
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance);
// Set the index "solver"
- $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+ $resultInstance->solveResultIndex(UserDatabaseFrontend::DB_COLUMN_USERID, $frontendInstance, array($this, 'setUserId'));
// And finally set it
$this->setResultInstance($resultInstance);
// Is a previous result there?
if ((!$this->getResultInstance() instanceof SearchableResult) || ($this->getResultInstance()->count() == 0)) {
- // Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+ // Get a UserDatabaseFrontend instance
+ $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class');
// Create a search criteria
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $criteriaInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName());
$criteriaInstance->setLimit(1);
// Get a search result
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+ $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance);
// Set the index "solver"
- $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+ $resultInstance->solveResultIndex(UserDatabaseFrontend::DB_COLUMN_USERID, $frontendInstance, array($this, 'setUserId'));
// And finally set it
$this->setResultInstance($resultInstance);
* @return $primaryValue Value of the primary key based on database type
*/
public final function getPrimaryKey () {
- // Get a user database wrapper
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+ // Get a user database frontend
+ $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class');
- // Get the primary key back from the wrapper
- $primaryKey = $wrapperInstance->getPrimaryKeyValue();
+ // Get the primary key back from the frontend
+ $primaryKey = $frontendInstance->getPrimaryKeyValue();
// Get that field
$primaryValue = $this->getField($primaryKey);
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add search criteria
- $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $searchInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName());
$searchInstance->setLimit(1);
// Now get another criteria
// Add the search criteria for searching for the right entry
$updateInstance->setSearchInstance($searchInstance);
- // Set wrapper class name
- $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
+ // Set frontend class name
+ $updateInstance->setFrontendConfigEntry('user_db_frontend_class');
// Remember the update in database result
$this->getResultInstance()->add2UpdateQueue($updateInstance);
*/
public function isConfirmed () {
// Determine it
- $isConfirmed = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed'));
+ $isConfirmed = ($this->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed'));
// Return it
return $isConfirmed;
*/
public function isGuest () {
// Determine it
- $isGuest = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
+ $isGuest = ($this->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
// Return it
return $isGuest;
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember;
use Org\Mxchange\CoreFramework\Registry\Registerable;
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add search criteria
- $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $searchInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName());
$searchInstance->setLimit(1);
// Now get another criteria
// Add the search criteria for searching for the right entry
$updateInstance->setSearchInstance($searchInstance);
- // Set wrapper class name
- $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
+ // Set frontend class name
+ $updateInstance->setFrontendConfigEntry('user_db_frontend_class');
// Remember the update in database result
$this->getResultInstance()->add2UpdateQueue($updateInstance);
namespace Org\Mxchange\CoreFramework\Deprecated;
// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Generic\FrameworkException;
/**
$messageArray[0]->__toString(),
$this->getLine(),
$messageArray[1],
- $messageArray[0]->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS)
+ $messageArray[0]->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS)
);
// Make sure everything is assigned properly
*/
interface Criteria extends FrameworkInterface {
/**
- * Setter for wrapper class name
+ * Setter for frontend class name
*
- * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name
+ * @param $frontendConfigEntry Configuration entry which hold the frontend class' name
* @return void
*/
- function setWrapperConfigEntry (string $wrapperConfigEntry);
+ function setFrontendConfigEntry (string $frontendConfigEntry);
/**
- * Getter for wrapper class name
+ * Getter for Frontend class name
*
- * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name
+ * @return $frontendConfigEntry Configuration entry which hold the Frontend class' name
*/
- function getWrapperConfigEntry ();
+ function getFrontendConfigEntry ();
/**
* Checks whether given key is set
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Criteria\Criteria;
-use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
-
-/**
- * The general interface for all other database wrappers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-interface DatabaseWrapper extends FrameworkInterface {
- /**
- * Getter for index key
- *
- * @return $indexKey Index key
- */
- function getIndexKey();
-
- /**
- * Getter for last exception
- *
- * @return $lastException Last exception or NULL if none occured
- */
- function getLastException();
-
- /**
- * 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
- */
- function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
-
- /**
- * 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
- */
- function doSelectCountByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
-
- /**
- * Getter for primary key used in wrapped table
- *
- * @return $primaryKey Primary key used in wrapped table
- */
- function getPrimaryKeyValue();
-
- /**
- * Counts total rows of this table
- *
- * @return $count Total rows of this table
- */
- function countTotalRows();
-
-}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Frontend\Account;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
+use Org\Mxchange\CoreFramework\Registration\User\UserRegister;
+use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
+
+/**
+ * An interface for frontend handling manageable accounts
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface ManageableAccountFrontend extends DatabaseFrontend {
+ /**
+ * Handles inserting the registration data from a registration instance into the database
+ *
+ * @param $registrationInstance An instance of a registration class
+ * @return void
+ */
+ function insertRegistrationObject (UserRegister $registrationInstance);
+
+ /**
+ * Updates an user database entry with given result
+ *
+ * @param $resultInstance An instance of a UpdateableResult class
+ * @return void
+ */
+ function doUpdateByResult (UpdateableResult $resultInstance);
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Criteria\Criteria;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+
+/**
+ * The general interface for all other database frontends
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface DatabaseFrontend extends FrameworkInterface {
+ /**
+ * Getter for index key
+ *
+ * @return $indexKey Index key
+ */
+ function getIndexKey();
+
+ /**
+ * Getter for last exception
+ *
+ * @return $lastException Last exception or NULL if none occured
+ */
+ function getLastException();
+
+ /**
+ * 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
+ */
+ function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
+
+ /**
+ * 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
+ */
+ function doSelectCountByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
+
+ /**
+ * Getter for primary key used in wrapped table
+ *
+ * @return $primaryKey Primary key used in wrapped table
+ */
+ function getPrimaryKeyValue();
+
+ /**
+ * Counts total rows of this table
+ *
+ * @return $count Total rows of this table
+ */
+ function countTotalRows();
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Database\Frontend\Points;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
+use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
+
+/**
+ * An interface for frontend dealing with bookable points
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface BookablePointsFrontend extends DatabaseFrontend {
+ /**
+ * Inserts the given points for the given user in the database
+ *
+ * @param $pointsInstance An instance of a user class
+ * @return void
+ */
+ function insertUserPoints (BookablePoints $pointsInstance);
+
+ /**
+ * Updates an user database entry with given result
+ *
+ * @param $resultInstance An instance of a UpdateableResult class
+ * @return void
+ */
+ function doUpdateByResult (UpdateableResult $resultInstance);
+
+}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Database\Frontend\Points;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
-use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
-
-/**
- * An interface for wrapper dealing with bookable points
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-interface BookablePointsWrapper extends DatabaseWrapper {
- /**
- * Inserts the given points for the given user in the database
- *
- * @param $pointsInstance An instance of a user class
- * @return void
- */
- function insertUserPoints (BookablePoints $pointsInstance);
-
- /**
- * Updates an user database entry with given result
- *
- * @param $resultInstance An instance of a UpdateableResult class
- * @return void
- */
- function doUpdateByResult (UpdateableResult $resultInstance);
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Wrapper\Account;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
-use Org\Mxchange\CoreFramework\Registration\User\UserRegister;
-use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
-
-/**
- * An interface for wrapper handling manageable accounts
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-interface ManageableAccountWrapper extends DatabaseWrapper {
- /**
- * Handles inserting the registration data from a registration instance into the database
- *
- * @param $registrationInstance An instance of a registration class
- * @return void
- */
- function insertRegistrationObject (UserRegister $registrationInstance);
-
- /**
- * Updates an user database entry with given result
- *
- * @param $resultInstance An instance of a UpdateableResult class
- * @return void
- */
- function doUpdateByResult (UpdateableResult $resultInstance);
-
-}
// Import framework stuff
use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
/**
* @para $callBack Call-back object for setting the index
* @return void
*/
- function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack);
+ function solveResultIndex ($databaseColumn, DatabaseFrontend $frontendInstance, array $callBack);
}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Database\Frontend;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
+
+/**
+ * A trait for database frontend
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait DatabaseFrontendTrait {
+ /**
+ * An instance of a DatabaseFrontend class
+ */
+ private $frontendInstance = NULL;
+
+ /**
+ * Setter for DatabaseFrontend instance
+ *
+ * @param $frontendInstance An instance of a DatabaseFrontend class
+ * @return void
+ */
+ public final function setFrontendInstance (DatabaseFrontend $frontendInstance) {
+ $this->frontendInstance = $frontendInstance;
+ }
+
+ /**
+ * Getter for DatabaseFrontend instance
+ *
+ * @return $frontendInstance An instance of a DatabaseFrontend class
+ */
+ public final function getFrontendInstance () {
+ return $this->frontendInstance;
+ }
+
+}