FredyH / MySQLOO

MySQLOO
GNU Lesser General Public License v2.1
140 stars 55 forks source link

Request: Query:getDB(), Query:getSQL() #98

Closed 2048khz-gachi-rmx closed 2 years ago

2048khz-gachi-rmx commented 2 years ago

word Currently using the lua equivalent, but (imo) it should be in the module itself

local DB = FindMetaTable("MySQLOO Database")
local QRY = FindMetaTable("MySQLOO Query")

DB._realQuery = DB._realQuery or DB.query

function DB:query(str)
    local qObj = self:_realQuery(str)

    qObj._fromDb = self
    qObj._strQry = str

    return qObj
end

function QRY:GetSQL()
    return self._strQry
end

function QRY:GetDB()
    return self._fromDb
end
FredyH commented 2 years ago

This would be easy to add. However, what would be the use case for being able to get the database of a query or the query string?

2048khz-gachi-rmx commented 2 years ago

Don't need it anymore, thought the db needs reconnecting manually if connection is lost (it doesn't), so i wanted to keep a reference around in the query object itself in case that's necessary