|
PA wrote:
like this ( not finished and tested of curse) function DB(filename) self = self or {} function self:Select(selectParam) return { Where = function (self,wherest) self.where = wherest return self end, From = function (self,fromst) self.from = fromst return self end, OrderBy = function (self,orderst) self.order = orderst return self end, Go = function (self) self.order = self.order or "" self.from = self.from or "" self.where = self.where or "" selectParam = selectParam or "*" db = sqlite.open(filename) for row in db:rows("SELECT ".. self.selectst .. "FROM " .. self.from .. "WHERE " .. self.where .. "ORDER BY " .. self.order) do print(unpack(row)) end end } end return self end DB('somefile'):Select('name,phone'):From('employes'):Where('ID >0'):OrderBy('name'):Go() |