mirror of
https://github.com/friendica/friendica
synced 2025-04-25 21:50:12 +00:00
Moving from DBA to Database
This commit is contained in:
parent
5e4ace271b
commit
082634adbc
11 changed files with 1778 additions and 1211 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue