• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Lua] Database Query problems.

zippoxer

Active Member
Joined
Mar 18, 2008
Messages
105
Reaction score
44
Location
Israel
I have this query:

Code:
local result = db.getResult("SELECT * FROM next_login_items WHERE player_id = " .. getPlayerGUID(cid));

I just want to get all the rows and loop over them. How can I do that?
 
Last edited:
Solution
Code:
	local result = db.getResult("SELECT * FROM next_login_items WHERE player_id = " .. getPlayerGUID(cid) .. ";")
	if result:getID() ~= -1 then
		repeat
			local cur = result:getDataInt("NAME OF COLUMN")
			-- all your code here
		until not result:next()
		result:free()
	end
Code:
	local result = db.getResult("SELECT * FROM next_login_items WHERE player_id = " .. getPlayerGUID(cid) .. ";")
	if result:getID() ~= -1 then
		repeat
			local cur = result:getDataInt("NAME OF COLUMN")
			-- all your code here
		until not result:next()
		result:free()
	end
 
Solution
Code:
	local result = db.getResult("SELECT * FROM next_login_items WHERE player_id = " .. getPlayerGUID(cid) .. ";")
	if result:getID() ~= -1 then
		repeat
			local cur = result:getDataInt("NAME OF COLUMN")
			-- all your code here
		until not result:next()
		result:free()
	end

Thanks it's working!
 
Back
Top