aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Core/Core.pm
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2016-11-20 19:30:58 +0100
committerDarkelarious <darkelarious@333networks.com>2016-11-20 19:30:58 +0100
commit702d1898b012d6d992d66b996508610890bf2963 (patch)
tree9556d890c4afdb7062f5b63277aa6b3d5c5d9d03 /lib/MasterServer/Core/Core.pm
parentc3f8d65a4fb1f5674557ee67cf7f74369df86ad1 (diff)
downloadMasterServer-Perl-702d1898b012d6d992d66b996508610890bf2963.tar.gz
MasterServer-Perl-702d1898b012d6d992d66b996508610890bf2963.zip
Restore SQLite support
Diffstat (limited to 'lib/MasterServer/Core/Core.pm')
-rwxr-xr-xlib/MasterServer/Core/Core.pm27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/MasterServer/Core/Core.pm b/lib/MasterServer/Core/Core.pm
index 3f99a3a..be0646b 100755
--- a/lib/MasterServer/Core/Core.pm
+++ b/lib/MasterServer/Core/Core.pm
@@ -35,15 +35,34 @@ sub halt {
################################################################################
## Set up the database connection
+## determine the type of database and load the appropriate module
################################################################################
sub select_database_type {
my $self = shift;
+
+ # read from login
+ my @db_type = split(':', $self->{dblogin}->[0]);
- # Connect to database
- $self->{dbh} = $self->database_login();
+ # format supported?
+ if ( "Pg SQLite mysql" =~ m/$db_type[1]/i) {
- # and test whether we succeeded.
- $self->halt() unless (defined $self->{dbh});
+ # inform us what DB we try to load
+ $self->log("load","Loading $db_type[1] database module.");
+
+ # load dbd and tables/queries for this db type
+ MasterServer::load_recursive("MasterServer::Database::$db_type[1]");
+
+ # Connect to database
+ $self->{dbh} = $self->database_login();
+
+ # and test whether we succeeded.
+ $self->halt() unless (defined $self->{dbh});
+ }
+ else {
+ # raise error and halt
+ $self->log("fatal", "The masterserver could not determine the chosen database type.");
+ $self->halt();
+ }
}
################################################################################