[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: '__iter', yet again!
- From: Petite Abeille <petite_abeille@...>
- Date: Wed, 16 Dec 2009 20:30:09 +0100
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?
- References:
- Re: '__iter', yet again!, Jerome Vuarand
- Re: '__iter', yet again!, Jerome Vuarand
- Re: '__iter', yet again!, Luiz Henrique de Figueiredo
- Re: '__iter', yet again!, steve donovan
- Re: '__iter', yet again!, Javier Guerra
- Re: '__iter', yet again!, Mark Hamburg