MisterQuestions Posted January 5, 2015 Share Posted January 5, 2015 Hey all sorry for beeing selfish on last post.. I have a problem saving player data, when he quit, this suposes to update their data on mysql table. But this updates, all the table values, why?? or how to set just update player row? function server.logout( thePlayer ) if ( thePlayer ~= "" ) then if ( getElementData( thePlayer, "Connection" ) == 1 ) then local save = dbQuery(databaseINFO.connection, "UPDATE ffw_users SET IngameName= ?" , getPlayerName( thePlayer ) ) -- Current InGame Name dbFree( save ) end end end addEventHandler("onPlayerQuit", getRootElement(), function() server.logout( source ) end ) Link to comment
Castillo Posted January 5, 2015 Share Posted January 5, 2015 Because you aren't specifying to who to set the data to, you need to specifiy it with his account name or whatever you are using, like this: dbExec ( databaseINFO.connection, "UPDATE ffw_users SET IngameName = ? WHERE AccountName = ?", getPlayerName ( thePlayer ), getAccountName ( getPlayerAccount ( thePlayer ) ) ) Also, use dbExec instead of dbQuery, since you don't need to get any data from it, just to know if it updated or not ( true/false ). Link to comment
MisterQuestions Posted January 5, 2015 Author Share Posted January 5, 2015 So, instead of accountname can i use player forum id? Link to comment
Castillo Posted January 5, 2015 Share Posted January 5, 2015 Use whatever you are using to identify who's data belongs to who. Link to comment
MisterQuestions Posted January 6, 2015 Author Share Posted January 6, 2015 And if i need to save multiple data, its posibble use it on same dbExec?? Link to comment
Castillo Posted January 6, 2015 Share Posted January 6, 2015 You can set multiple columns in a single query, simply use commas to separate them, like this: "UPDATE ffw_users SET IngameName = ?, MySecondData = ?, MyThirdData = ? WHERE AccountName = ?" Link to comment
Bonsai Posted January 6, 2015 Share Posted January 6, 2015 Hey all sorry for beeing selfish on last post..I have a problem saving player data, when he quit, this suposes to update their data on mysql table. But this updates, all the table values, why?? or how to set just update player row? function server.logout( thePlayer ) if ( thePlayer ~= "" ) then if ( getElementData( thePlayer, "Connection" ) == 1 ) then local save = dbQuery(databaseINFO.connection, "UPDATE ffw_users SET IngameName= ?" , getPlayerName( thePlayer ) ) -- Current InGame Name dbFree( save ) end end end addEventHandler("onPlayerQuit", getRootElement(), function() server.logout( source ) end ) In case of deleting Link to comment
MisterQuestions Posted January 6, 2015 Author Share Posted January 6, 2015 Im not gonna delete it .-., but what evah u think... 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