Jump to content

Getting Last ID From SQL


Jalapeno

Recommended Posts

Posted
--Row 76
function GetLastDBID()
	local dbMuv = dbQuery( handler, "SELECT * FROM rust_items ORDER BY `id` DESC" )
	local result = dbPoll(dbMuv, -1)
	if (#result>0) then
		for _, row in ipairs ( result ) do
			id = tonumber(row["id"])
			return id
			break
		end
	end
end
addEvent("GetLastDBID", true)
addEventHandler("GetLastDBID", root, GetLastDBID)
--Row90

Hy guys, i have a little problem with this code, i wan't to get the last item id from my sql table but something doesen't work....

DebugScript:

ERROR: Loading script failed: Inventory\codeS.lua:84 'end' expected (to close 'for' at line 81) near 'break'

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...