Discord Moderators Pirulax Posted June 21, 2017 Discord Moderators Share Posted June 21, 2017 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. Link to comment
Hale Posted June 21, 2017 Share Posted June 21, 2017 dbExec isn't supposed to return anything. You aren't using dbExec properly, please open the function in wiki and carefully read it (Usage of '?' and '??'). 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. Link to comment
Discord Moderators Pirulax Posted June 22, 2017 Author Discord Moderators Share Posted June 22, 2017 (edited) 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 June 22, 2017 by Pirulax Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now