*/
private static $configurationInstance = NULL;
+ /**
+ * Database instance
+ */
+ private static $databaseInstance = NULL;
+
/*
* Includes applications may have. They will be tried in the given order,
* some will become soon deprecated.
return self::$configurationInstance;
}
- /**
- * Getter for request instance
- *
- * @return $requestInstance An instance of a Requestable class
- */
- public static function getRequestInstance () {
- return self::$requestInstance;
- }
-
- /**
- * Getter for response instance
- *
- * @return $responseInstance An instance of a Responseable class
- */
- public static function getResponseInstance () {
- return self::$responseInstance;
- }
-
/**
* "Getter" to get response/request type from analysis of the system.
*
$applicationInstance = ApplicationHelper::getSelfInstance();
// Is the database instance already set?
- if ($applicationInstance->getDatabaseInstance() instanceof DatabaseConnector) {
+ if (self::getDatabaseInstance() instanceof DatabaseConnector) {
// Yes, then abort here
throw new BadMethodCallException('Method called twice.');
} // END - if
$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
// Set it in application helper
- $applicationInstance->setDatabaseInstance($connectionInstance);
+ self::setDatabaseInstance($connectionInstance);
}
/**
self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
self::getConfigurationInstance()->setConfigEntry('detected_app_name' , $application);
}
+
+ /**
+ * Getter for request instance
+ *
+ * @return $requestInstance An instance of a Requestable class
+ */
+ public static function getRequestInstance () {
+ return self::$requestInstance;
+ }
+
+ /**
+ * Getter for response instance
+ *
+ * @return $responseInstance An instance of a Responseable class
+ */
+ public static function getResponseInstance () {
+ return self::$responseInstance;
+ }
+
/**
* Setter for request instance
*
self::$responseInstance = $responseInstance;
}
+ /**
+ * Setter for database instance
+ *
+ * @param $databaseInstance An instance of a DatabaseConnection class
+ * @return void
+ */
+ public static function setDatabaseInstance (DatabaseConnection $databaseInstance) {
+ self::$databaseInstance = $databaseInstance;
+ }
+
+ /**
+ * Getter for database instance
+ *
+ * @return $databaseInstance An instance of a DatabaseConnection class
+ */
+ public static function getDatabaseInstance () {
+ // Return instance
+ return self::$databaseInstance;
+ }
+
}
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;
} // END - if
// Handle it over to the middleware
- $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+ FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
}
/**
} // END - if
// Handle it over to the middleware
- $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+ FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
}
/**
* @return $indexKey Index key
*/
public final function getIndexKey () {
- return $this->getDatabaseInstance()->getIndexKey();
+ return FrameworkBootstrap::getDatabaseInstance()->getIndexKey();
}
/**
* @return $lastException Last exception or NULL if none occured
*/
public final function getLastException () {
- return $this->getDatabaseInstance()->getLastException();
+ return FrameworkBootstrap::getDatabaseInstance()->getLastException();
}
/**
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
// Now it's time to ask the database layer for this select statement
- $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
+ $result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: result[]=' . gettype($result));
// Cache the result if not null
// This invalid result must be wrapped
$result = array(
BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid',
- BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => $this->getDatabaseInstance()->getLastException()
+ BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException()
);
}
}
*/
public final function getPrimaryKeyValue () {
// Get the table name and a database instance and ask for it
- $primaryKey = $this->getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName());
+ $primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName());
// Return value
return $primaryKey;
*/
public final function countTotalRows () {
// Get the table name and a database instance and ask for it
- $count = $this->getDatabaseInstance()->countTotalRows($this->getTableName());
+ $count = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName());
// Return value
return $count;
*/
public function removeNonPublicDataFromArray (array $data) {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling this->getDatabaseInstance()->removeNonPublicDataFromArray(data) ...');
- $data = $this->getDatabaseInstance()->removeNonPublicDataFromArray($data);
+ $data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data));
return $data;
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;
$resultInstance->addElementsToDataSet($dataSetInstance);
// "Update" this request with the database
- $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+ FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
}
}
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;
$dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID);
// "Update" this request with the database
- $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+ FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
}
}
$this->fixedSalt = sha1(
$serverIp . ':' .
$extraInstance->__toString() . ':' .
- json_encode($this->getDatabaseInstance()->getConnectionData())
+ json_encode(FrameworkBootstrap::getDatabaseInstance()->getConnectionData())
);
} else {
// Without extra information
- $this->fixedSalt = sha1($serverIp . ':' . json_encode($this->getDatabaseInstance()->getConnectionData()));
+ $this->fixedSalt = sha1($serverIp . ':' . json_encode(FrameworkBootstrap::getDatabaseInstance()->getConnectionData()));
}
// One-way data we need for "extra-salting" the random number