I was banging my head against the wall trying to figure out how to use sqlite prepared statements, and I finally got it. Hopefully this small example will save someone some time.
-- insert a new item into a specific set and return the id of the new item
function createSetItem(theSetID,theSetItem)
local stmt = db:prepare([[INSERT INTO setItems (setID,item) VALUES (:pSetID, :pItem)]])
stmt:bind\_names({pSetID = theSetID, pItem = theSetItem})
stmt:step()
local newID = db:last\_insert\_rowid()
print("newID: ", newID)
return newID
end
[import]uid: 207504 topic_id: 19231 reply_id: 142637[/import]