Moving from DBA to Database

This commit is contained in:
Philipp Holzer 2019-06-07 00:10:45 +02:00
parent 5e4ace271b
commit 082634adbc
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
11 changed files with 1778 additions and 1211 deletions

View file

@ -17,14 +17,11 @@ class DBFactory
* @param Profiler $profiler The profiler
* @param array $server The $_SERVER variables
*
* @return Database\Database
* @throws \Exception if connection went bad
*/
public static function init(Cache\IConfigCache $configCache, Profiler $profiler, array $server)
{
if (Database\DBA::connected()) {
return;
}
$db_host = $configCache->get('database', 'hostname');
$db_user = $configCache->get('database', 'username');
$db_pass = $configCache->get('database', 'password');
@ -50,11 +47,15 @@ class DBFactory
$db_data = $server['MYSQL_DATABASE'];
}
if (Database\DBA::connect($configCache, $profiler, new VoidLogger(), $db_host, $db_user, $db_pass, $db_data, $charset)) {
$database = new Database\Database($configCache, $profiler, new VoidLogger(), $db_host, $db_user, $db_pass, $db_data, $charset);
if ($database->connected()) {
// Loads DB_UPDATE_VERSION constant
Database\DBStructure::definition($configCache->get('system', 'basepath'), false);
}
unset($db_host, $db_user, $db_pass, $db_data, $charset);
return $database;
}
}