Pirulax

What can return affected row number? | dbExec returning nil.

Recommended Posts

So, i have a little code ==>

id,charname,anick,dead,ajail,otherdata,skinid,pos,bones,health,hunger = 
getElementData(client, "acc:id"), name,"admin",toJSON({0, false}),
toJSON({false, 0, "", "", 0}),toJSON({szuldate,varos,age,cm,kg}), skinid,toJSON(spawnPosTable),toJSON({})--[[csontok..]],100,100

theXec = dbExec(con, "INSERT INTO characters SET id=?,charname=?,anick=?,dead=?,ajail=?,otherdata=?,skinid=?,pos=?,bones=?,health=?,hunger=?",
id,charname,anick,dead,ajail,otherdata,skinid,pos,bones,health,hunger)
if theXec then
  --doSomething
else
  --doSomething else
end
outputDebugString(tostring(theXec))

All the variables have their value, but for some reason dbExec is returning nil.And does nothing.((Nothing in the Db tho))

My 2nd question is:

What can return a number of affected rows?I have a query: "SELECT * FROM accounts WHERE id=?", and i want to get the number of affected rows.

Share this post


Link to post
  1. dbExec isn't supposed to return anything.
  2. You aren't using dbExec properly, please open the function in wiki and carefully read it (Usage of '?' and '??').
  3. dbPoll returns a second argument, which is the number of affected rows. Again, read more about it on wiki, there are good examples on how to use it as well.

Share this post


Link to post

I know, that dbPoll returns the number of affected rows, last insert id, and a table too.

From the MTA Wiki ==>

 

Quote

 

Returns

Returns true unless the connection is incorrect, in which case it returns false.

 

Btw, if im not using dbExec propertly, then go and try to run a script like this,and it will succeed.

dbExec(con "SELECT * FROM accounts WHERE id=?", 1)

This will return true most likely.

Edited by Pirulax

Share this post


Link to post

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.