From 67697f6125466cc76ae07f2757afc7fef5db5e23 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 12 May 2013 04:12:17 +0200 Subject: Properly recycling connections. --- lib/dblib.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/dblib.lua b/lib/dblib.lua index 64ce880..3840657 100644 --- a/lib/dblib.lua +++ b/lib/dblib.lua @@ -1078,7 +1078,9 @@ luadb = { -- get into a registry to fetch "id" -- else -- end + local olddb if type(id) == "table" and type(id._) == "table" then + olddb = id user = id._.user password = id._.password base = id._.base @@ -1086,6 +1088,7 @@ luadb = { id = id._.id end db = SQLConnection(id, user, password, base) + if olddb then olddb._.conn = db end return { opentable = _luadb.opentable, SafeQuery = _luadb.mysql.SafeQuery, @@ -1119,7 +1122,9 @@ luadb = { l_env:setExceptions(false) end + local olddb if type(id) == "table" and type(id._) == "table" then + olddb = id user = id._.user password = id._.password base = id._.base @@ -1130,6 +1135,7 @@ luadb = { if not conn then return nil, l_env:getErrorCode(), l_env:getErrorMsg() end + if olddb then olddb._.conn = conn end return { opentable = _luadb.opentable, SafeQuery = _luadb.oracle.SafeQuery, -- cgit v1.2.3