Jump to content

Need help with my db error


areoslasher

Recommended Posts

So basically I'm trying to get all of my data from my database to create bank markers around the city but for some reason I'm really having difficult time with this.. I don't understand why is this error happening but anyways.. I'll post snippet of the code and errors down below.. thanks in advanced

 

addEventHandler('onResourceStart', resourceRoot, function() 

	local db = exports.database:getConnectionToDb()

    dbQuery(loadAllBanks, db, 'SELECT * FROM banks')

end)

function loadAllBanks()
	local results = dbPoll(queryHandle, 0)
    for i,marker in pairs(results) do
        local bankMarkerObj = createMarker(marker.x, marker.y, marker.z, "cylinder", 1.5, 100, 255, 100, 50 )
        setElementData(bankMarkerObj, "id", marker.id)
		if(marker.isATM == 1) then
			setElementData(bankMarkerObj, "type", 'ATM')
		else
			setElementData(bankMarkerObj, "type", 'Bank')
		end
    end
end

and errors:

" WARNING: money\bank.lua:4 Bad argument @'dbPoll' [Expected db-query at argument 1, got nil] "
"ERROR: money\bank.lua:5: Bad argument #1 to 'pairs' (table expected, got boolean)"

More info:
error happens cuz of dbPoll not getting it's query and that's why I need help.
yes, I have tried dbFree
 the query should return one row at the moment
**NOTE** local results are not that tabbed in, the snippet got messed up

Link to comment

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...