aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Core/Core.pm
diff options
context:
space:
mode:
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();
+ }
}
################################################################################