How do you use parameterized query in LuaSQLite 3?
I've tried understanding the documentations at:
http://luasqlite.luaforge.net/lsqlite3.html#methods for prepared statements
and looked at the example here:
How to quote values for LuaSQL?
but I can't get this to work:
getTable = function( _key)
local path = system.pathForFile("database.db", system.ResourceDirectory)
local dc = sqlite3.open( path )
local stmt = dc:prepare[[ SELECT * FROM Table WHERE Key = :Key ]]
local sql = stmt:bind({key=_weaponType})
return dc:nrows(sql)
end
I get the error:
attempt to index 'stmt' (a nil value)
on the line:
local sql = stmt:bind({key=_weaponType})
P.S. I'm currently developing a game in Corona SDK.