如何在LuaSQLite 3中使用參數化查詢?如何在LuaSQLite 3中使用參數化查詢?
我試過在理解單證:
http://luasqlite.luaforge.net/lsqlite3.html#methods準備語句
,看着這裏的例子:
How to quote values for LuaSQL?
,但我不能得到這個工作:
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
我得到的錯誤:
attempt to index 'stmt' (a nil value)
就行了:
local sql = stmt:bind({key=_weaponType})
附:我目前正在Corona SDK中開發一款遊戲。
我沒有意識到在LUA中可能有更多1的返回值!謝謝,這幫助我解決了我的問題。 –
你剛剛做了一個Lua大寫意外事件:它只是lua(你沒有PYTHON):) – daurnimator