X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fdatabase%2Fwrapper%2Fclass_UserDatabaseWrapper.php;h=88bc13fbb24e1ee3b91782005888fb2431f26b4f;hb=389f3abad52f9cde3323db5d3d187562fe801a71;hp=c8eb465c2b3e313b29cb753dae071d0b832708f3;hpb=1f1f351e726dae5d4cd25b46639c2fcaa9e38661;p=hub.git diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index c8eb465c2..88bc13fbb 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -33,6 +33,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { // Constants for database columns const DB_COLUMN_USERNAME = "username"; + const DB_COLUMN_EMAIL = "email"; // Constants for database table names const DB_TABLE_USER = "user"; @@ -50,7 +51,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { $this->setObjectDescription("Database wrapper for user objects"); // Create unique ID number - $this->createUniqueID(); + $this->generateUniqueId(); } /** @@ -103,8 +104,17 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { // Now it's time to ask the database layer for this select statement $result = $this->getDatabaseInstance()->doSelectByTableCriteria(self::DB_TABLE_USER, $criteriaInstance); - // Cache the result - $this->cacheInstance->offsetSet($cacheKey, $result); + // Cache the result if not null + if (!is_null($result)) { + // A valid result has returned from the database layer + $this->cacheInstance->offsetSet($cacheKey, $result); + } else { + // This invalid result must be wrapped + $result = array( + 'status' => "invalid", + 'exception' => $this->getDatabaseInstance()->getLastException() + ); + } } // Create an instance of a DatabaseResult class with the given result @@ -113,6 +123,24 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { // And return the instance return $resultInstance; } + + /** + * 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'); + $dataSetInstance->setTableName(self::DB_TABLE_USER); + + // Add registration elements to the dataset + $registrationInstance->addElementsToDataSet($dataSetInstance); + + // "Insert" this request instance completely into the database + $this->getDatabaseInstance()->insertDataSet($dataSetInstance); + } } // [EOF]