【发布时间】:2019-10-08 17:53:52
【问题描述】:
我用 LUA 和 SQL 语句来说明。我已经尝试过了,我可以显示一个 SELECT 或进行一个 UPDATE、INSERT ...但我不知道如何将一个唯一返回的选择值分配给一个变量
mysql = require "luasql.mysql"
env = mysql.mysql()
conn = env:connect('table','user','pass','server')
--print(env,conn)
cursor,errorString = conn:execute([[select id from agent where extension = '9072']])
--print(cursor,errorString)
row = cursor:fetch ({}, "a")
while row do
print(string.format("%s", row.id))
row = cursor:fetch (row, "a")
end
-- close everything
cursor:close()
conn:close()
env:close()
我希望是这样的: 值=33
【问题讨论】:
-
这些例子对你有帮助吗? keplerproject.github.io/luasql/examples.html