lua-users home
lua-l archive

Re: SQL syntax in Lua?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


PA wrote: [lisa@thecommune.org.uk> wrote:
PA wrote:
> Thoughts?

Clone Apples CoreData Entity-Relationship modeling system? It's pretty
much intended to do exactly as you've described.


Hmmm... yes... not quite CoreData, but rather something along the line of its ancestor, 'good, old' EOF, with a lighter syntax for the EOFetchSpecification and associated EOQualifier(s).

http://developer.apple.com/documentation/WebObjects/Enterprise_Objects/index.html
http://developer.apple.com/documentation/WebObjects/Reference/API/com/webobjects/eocontrol/EOQualifier.html
http://developer.apple.com/documentation/WebObjects/Reference/API/com/webobjects/eocontrol/EOFetchSpecification.html





--
Cheers

--
PA
http://alt.textdrive.com/

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()



AltStyle によって変換されたページ (->オリジナル) /