Fixes error in database selection

main
Yasen Pramatarov 2024-08-10 21:57:41 +03:00
parent aeb837fee5
commit e6d6a10795
5 changed files with 49 additions and 31 deletions

View File

@ -1,7 +1,22 @@
<?php <?php
// connect to database // connect to database
function connectDB($config) { function connectDB($config,$database) {
if ($database === 'jilo') {
try {
$db = new Database([
'type' => 'sqlite',
'dbFile' => $config['jilo_database'],
]);
} catch (Exception $e) {
$error = 'Error: ' . $e->getMessage();
include 'templates/block-message.php';
exit();
}
} else {
// sqlite database file // sqlite database file
if ($config['db_type'] === 'sqlite') { if ($config['db_type'] === 'sqlite') {
try { try {
@ -38,6 +53,9 @@ function connectDB($config) {
include 'templates/block-message.php'; include 'templates/block-message.php';
exit(); exit();
} }
}
return $db; return $db;
} }
?> ?>

View File

@ -5,7 +5,7 @@ require 'classes/component.php';
// connect to database // connect to database
require 'helpers/database.php'; require 'helpers/database.php';
$db = connectDB($config); $db = connectDB($config, 'jilo');
// FIXME move thi sto a special function // FIXME move thi sto a special function
$time_range_specified = false; $time_range_specified = false;

View File

@ -5,7 +5,7 @@ require 'classes/conference.php';
// connect to database // connect to database
require 'helpers/database.php'; require 'helpers/database.php';
$db = connectDB($config); $db = connectDB($config, 'jilo');
// FIXME move thi sto a special function // FIXME move thi sto a special function
$time_range_specified = false; $time_range_specified = false;

View File

@ -6,7 +6,7 @@ require 'classes/participant.php';
// connect to database // connect to database
require 'helpers/database.php'; require 'helpers/database.php';
$db = connectDB($config); $db = connectDB($config, 'jilo');
// //

View File

@ -5,7 +5,7 @@ require 'classes/participant.php';
// connect to database // connect to database
require 'helpers/database.php'; require 'helpers/database.php';
$db = connectDB($config); $db = connectDB($config, 'jilo');
// FIXME move thi sto a special function // FIXME move thi sto a special function
$time_range_specified = false; $time_range_specified = false;