Jump to content

Little mysql


Pirulax

Recommended Posts

  • Discord Moderators

Hello guys!I know its a little bit stupid question, but i cant get this code to work.. 

if dbExec(con, "SELECT * FROM groupattach WHERE characterID = ? AND groupID = ?", getElementData(targetPlayer, "char:id"), fraction) == nil then 
	--do something
end

connection is working, the query is working, but the IF statment not.. i think because it is a table, and it cant be nil?

Link to comment

The dbExec returns a table so, if you want to make something like this you should use :

dbExec() -- Like in your code
dbPoll() -- Because you need the result of your dbExec

And you could use the '#' to count the number of lines into the returned result of your dbPoll

If you've any other question, ask here.

Edited by Gordon_G
Link to comment
  • Discord Moderators

so:

 

	result = dbPoll(dbQuery(con, "SELECT * FROM groupattach WHERE characterID = ? AND groupID = ?", getElementData(targetPlayer, "char:id"), fraction), -1)
	if #result == 0 then
		---do something
	end

 

 

Edited by Pirulax
Correcting #result = to #result ==
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...