控制台错误;
117: call: failed to call 'mysql:select' [string "?"]
117: bad argument #1 to 'ipairs' <table expected, got boolean>
功能;
function openAdvertisements( player, command )
local advertisements = { } --These will hold our advertisements to send to the client and populate our advertisement tables.
if not player then player = source end
--Fetch all of the advertisements from the database
for _, ad in ipairs( exports.mysql:select('advertisements') ) do
if tonumber( ad.expiry ) >= tonumber( getRealTime().timestamp ) then --Check if the advertisement has expired, delete it if so.
ad.author = exports.mysql:select_one( "characters", { id = ad.created_by } ).charactername
table.insert( advertisements, ad )
else
deleteAdvertisement( ad.id )
end
end
triggerClientEvent( player, resourceName .. ":display_all", root, advertisements, exports.integration:isPlayerAdmin( player ) ) --Send the advertisements to the client to create the GUI.
end
第117行; for _,ad in ipairs(exports.mysql:select('advertisements'))do leaveCs(CID)
答案 0 :(得分:0)
当
exports.mysql:select('advertisements')
返回boolean
失败,您无法在ipairs
上使用boolean
,因为ipairs
可以与表格一起使用。
为什么exports.mysql:select('advertisements')
未能致电?
,因为 在表格周围加上引号,因为它们不是字符串 应该这样做
exports.mysql:select("SELECT * FROM 'advertisements' WHERE <something>")