lua-users home
lua-l archive

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


PA wrote:


On 3/8/06, Lisa Parratt <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.




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