Added possibility to disable database system

This commit is contained in:
Timo Smit 2017-02-04 19:02:08 +01:00
parent 7484421845
commit 218dce31b8

View file

@ -23,21 +23,27 @@ local db = {}
local con local con
function db.isconnected()
return (con ~= nil)
end
-- as this module serves as a wrapper/super class, we load the selected database -- as this module serves as a wrapper/super class, we load the selected database
-- system in this function. might have to think of a better way to implement -- system in this function. might have to think of a better way to implement
-- this, but it will suffice. -- this, but it will suffice.
function db.oninit() function db.oninit()
if settings.get("db_type") == "mysql" then if settings.get("db_type") ~= "none" then
con = require "luascripts.wolfadmin.db.mysql" if settings.get("db_type") == "mysql" then
elseif settings.get("db_type") == "sqlite3" then con = require "luascripts.wolfadmin.db.mysql"
con = require "luascripts.wolfadmin.db.sqlite3" elseif settings.get("db_type") == "sqlite3" then
else con = require "luascripts.wolfadmin.db.sqlite3"
error("invalid database system (choose mysql, sqlite3)") else
error("invalid database system (choose mysql, sqlite3)")
end
setmetatable(db, {__index = con})
db.start()
end end
setmetatable(db, {__index = con})
db.start()
end end
events.handle("onGameInit", db.oninit) events.handle("onGameInit", db.oninit)