• 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 Mysql database

mayel

New Member
Joined
Sep 11, 2009
Messages
174
Reaction score
2
Location
Stockholm, Sweden
Hello,


How do i get information from my mysql database with a mysql query?
I mean theres no point of having a database if you can't get the information later in scripts and so on.
I mean the getplayerpremiumdays function must get the pacc days information from my database somehow and i want to figure out how.

Please help.
If i could figure it out, it would be very helpful.

Thanks in advance and i'll for sure rep++ all helpful comments.
 
Code:
local ids, info = {}, db.getResult('SELECT `id` FROM `players`;')
if info:getID() ~= -1 then
	while info:next() do
		table.insert(ids, info:getDataInt('id'))
	end
	info:free()
end

print('>> Stored '.. #ids ..' IDs.')
 
Np, here's some other example that returns premium points of player:
Code:
function getPlayerPremiumPoints(cid)
	local points, res = 0, db.getResult('SELECT `premium_points` FROM `accounts` WHERE `id` = '.. getPlayerAccountId(cid) ..';')

	if res:getID() ~= -1 then
		points = res:getDataInt('premium_points')
		res:free()
	end

	return points
end
 
@ first example
Wrong Kamil ;<
Lua:
local ids, info = {}, db.getResult('SELECT `id` FROM `players`;')
if info:getID() ~= -1 then
	while (true)  do
		table.insert(ids, info:getDataInt('id'))
                if not(info:next()) then
                     break
                end

	end
	info:free()
end

print('>> Stored '.. #ids ..' IDs.')
 
@ first example
Wrong Kamil ;<
Lua:
local ids, info = {}, db.getResult('SELECT `id` FROM `players`;')
if info:getID() ~= -1 then
	while (true)  do
		table.insert(ids, info:getDataInt('id'))
                if not(info:next()) then
                     break
                end

	end
	info:free()
end

print('>> Stored '.. #ids ..' IDs.')

Code:
local ids, info = {}, db.getResult('SELECT `id` FROM `players`;')
if info:getID() ~= -1 then
	repeat
		table.insert(ids, info:getDataInt('id'))
	until info:next()
	info:free()
end

print('>> Stored '.. #ids ..' IDs.')

'<_<'
 
Back
Top