lua-users home
lua-l archive

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



On May 2, 2008, at 2:15 PM, Tomas Guisasola Gorham wrote:

a future release of LuaSQL would have a modified `fetch' method which closes the cursor when there is no more rows to retrieve.

This is also the approach taken by DB.lua: it automatically closes the connection cursor after the last row has been fetched.

local aDB = DB( 'mysql://localhost/test' )

for aContact in aDB( 'select * from contact' ) do
    print( aContact.name, aContact.email )
end

http://dev.alt.textdrive.com/browser/HTTP/DB.lua#L174

Alternatively, one can always close the cursor explicitly as well:

local aDB = DB( 'mysql://localhost/test' )
local aCursor = aDB( 'select * from contact' )

aCursor.close = true

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