• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Lua] Database Query problems.

zippoxer

Active Member
Joined
Mar 18, 2008
Messages
112
Reaction score
48
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