lua-users home
lua-l archive

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


On Dec 16, 2009, at 8:06 PM, Mark Hamburg wrote:

> 	for name in DBTable[ 'Customers' ]:where( 'Age', lessThan, 50 ):select( 'Name' ) do
> 		-- database extraction
> 	end

OMG, another (O)RM idiom! :P

Getting a hard time trying to comprehend what's the advantage of such baroque syntax over good, old, plain, byzantine SQL :)

FWIW, here is the syntax I tend to use:

local DB = require( 'DB' )
local aDB = DB( 'sqlite3://localhost/test.db' )

for aCustomer in aDB( 'select name from customer where age < 50' ) do
    print( aCustomer.name )
end

(0) plain SQL, got tired of trying to reinvent that wheel :D
(1) call db -> create a connection
(2) call connection -> create a cursor containing the result of a statement
(3) call cursor -> iterate over the cursor content

Just my 2¢.

P.S. What is it with December and language changes? Too much Glühwein or something?