gpt4 book ai didi

mysql - Lua 插入语句

转载 作者:太空宇宙 更新时间:2023-11-03 12:13:37 25 4
gpt4 key购买 nike

我的插入语句有问题:

Create = function (LN,FN,Add,Tel,Cell)
LastName = tostring(LN);
FirstName = tostring(FN);
Address = tostring(Add);
Telephone =tostring(Tel);
Cellphone = tostring(Cell);

--问题的根源

conn:execute([[INSERT INTO book(LastName, FirstName, Address, Telephone, Cellphone) VALUES ("]]"'"LastName"','"FirstName"','" Address"','" Telephone"','" Cellphone")]]'")

print ("\n Creating an account Successful")
end

最佳答案

我建议您使用 string.format用于放置数据:

Create = function (LN,FN,Add,Tel,Cell)
local LastName, FirstName, Address, Telephone, Cellphone = tostring(LN), tostring(FN), tostring(Add), =tostring(Tel), tostring(Cell)
local sQuery = [[INSERT INTO book(LastName, FirstName, Address, Telephone, Cellphone) VALUES ('%s', '%s', '%s', '%s', '%s')]]
conn:execute( sQuery:format(LastName, FirstName, Address, Telephone, Cellphone) )

关于mysql - Lua 插入语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23149761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com