Moves database connection to DatabaseConnector core class
parent
891e85b0bb
commit
13f2ca4fe4
|
@ -21,10 +21,10 @@ class DatabaseConnector
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$db = connectDB($config);
|
$db = connectDB($config);
|
||||||
if (!$db) {
|
if (!$db['db']) {
|
||||||
throw new Exception('Could not connect to database');
|
throw new Exception('Could not connect to database');
|
||||||
}
|
}
|
||||||
return $db;
|
return $db['db'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Show error and exit
|
// Show error and exit
|
||||||
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
||||||
|
|
|
@ -134,22 +134,10 @@ $public_pages = filter_public_pages($public_pages);
|
||||||
require_once __DIR__ . '/../app/core/Router.php';
|
require_once __DIR__ . '/../app/core/Router.php';
|
||||||
$currentUser = \App\Core\Router::checkAuth($config, $app_root, $public_pages, $page);
|
$currentUser = \App\Core\Router::checkAuth($config, $app_root, $public_pages, $page);
|
||||||
|
|
||||||
// connect to db of Jilo Web
|
// connect to DB via DatabaseConnector
|
||||||
require '../app/classes/database.php';
|
require_once __DIR__ . '/../app/core/DatabaseConnector.php';
|
||||||
require '../app/includes/database.php';
|
use App\Core\DatabaseConnector;
|
||||||
try {
|
$dbWeb = DatabaseConnector::connect($config);
|
||||||
$response = connectDB($config);
|
|
||||||
if (!$response['db']) {
|
|
||||||
throw new Exception('Could not connect to database: ' . $response['error']);
|
|
||||||
}
|
|
||||||
$dbWeb = $response['db'];
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
|
||||||
include '../app/templates/page-header.php';
|
|
||||||
include '../app/helpers/feedback.php';
|
|
||||||
include '../app/templates/page-footer.php';
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// start logging
|
// start logging
|
||||||
require '../app/classes/log.php';
|
require '../app/classes/log.php';
|
||||||
|
|
Loading…
Reference in New Issue