本地函数getList()
local select_stmt = db:prepare("SELECT * FROM list")
return select_stmt:rows();
end
local rows = getList();
--**here i need to print the rows list, how I can print using for loop**
--************************************************
**here I want to fetch single record, I am unable to fetch and print it?**
local function getListRecord(listId)
local select_stmt = db:prepare("SELECT * FROM list where id = ?")
select_stmt:bind_names{ id = listId }
return select_stmt:get_unames()-- i AM GETTING ERROR HERE
end
local row = getListRecord(3);
--I am unable to get the row here, please help me
答案 0 :(得分:0)
这与您昨天提出的问题相同 How to return array list in lua program?
for line,tblLine in pairs(rows) do
for key,data in pairs(tblLine) do
print(key,data)
end
end
如果要从列表中返回单行,并且您知道索引使用
row = rows[3]
正如其他回复中所建议的那样,你需要查看Lua中的Programming中的表格部分,因为这是在Lua做任何事情的关键。