Tekken Posted April 30, 2015 Share Posted April 30, 2015 HI, i need some help on toJSON and fromJSON. My problem is this: I save ID, NUMBER like this: local json = toJSON({ ID, NR }) Everything work's ok but I need to save like 20 ID's and 20NR's but each time will overwrite the old ID/NR and I don't want that... Any help ? Link to comment
Tekken Posted April 30, 2015 Author Share Posted April 30, 2015 I can't show my full code but SAVE local theID = getElementModel(element) local thenr = getElementHealth(element) local json = toJSON({theID, theNr}) --- Bla, bla dbQuery(db, "INSERT INTO table(json) VALUE(?)", json) LOAD local theID, theNr = unpack(fromJSON(json)) Link to comment
ALw7sH Posted April 30, 2015 Share Posted April 30, 2015 you used INSERT not UPDATE so nothing will be rewrited Link to comment
Tekken Posted April 30, 2015 Author Share Posted April 30, 2015 you used INSERT not UPDATEso nothing will be rewrited Yes but will still overwrite the old values... Link to comment
Tekken Posted April 30, 2015 Author Share Posted April 30, 2015 Ohh, man but that's my problem..., why don't you understaind ? IS OVERWRITING old values!! Link to comment
ALw7sH Posted April 30, 2015 Share Posted April 30, 2015 http://www.w3schools.com/sql/sql_insert.asp The INSERT INTO statement is used to insert new records in a table. Link to comment
Tekken Posted April 30, 2015 Author Share Posted April 30, 2015 Do you know how to/fromJSON work's ? when i send that data in THE SAME json will OVERRITE old data! and keep only the last one. Link to comment
Walid Posted April 30, 2015 Share Posted April 30, 2015 Do you know how to/fromJSON work's ? when i send that data in THE SAME json will OVERRITE old data! and keep only the last one. Man you are inserting new values every time did you tired : dbExec(db, "UPDATE table(json) SET value = ? WHERE yourData = ?", json) Link to comment
Tekken Posted April 30, 2015 Author Share Posted April 30, 2015 Do you know how to/fromJSON work's ? when i send that data in THE SAME json will OVERRITE old data! and keep only the last one. Man you are inserting new values every time did you tired : dbExec(db, "UPDATE table(json) SET value = ? WHERE yourData = ?", json) this will just give NULL. Link to comment
Walid Posted April 30, 2015 Share Posted April 30, 2015 (edited) dbExec(db, "UPDATE table(json) SET value = ? WHERE yourData = ?", json) this will just give NULL. maybe you did something wrong that's why i asked you to show me your code. Edited May 1, 2015 by Guest Link to comment
Tekken Posted May 1, 2015 Author Share Posted May 1, 2015 Everything works ok only that thing, and i think that's normal, I came here because i thought somebody will give me a better idea. Link to comment
ALw7sH Posted May 1, 2015 Share Posted May 1, 2015 How we can help you if you dont want to show us your full codes? and the way that you reply us is so rude Link to comment
Tekken Posted May 1, 2015 Author Share Posted May 1, 2015 How we can help you if you dont want to show us your full codes? and the way that you reply us is so rude I was a bit angry because i have some problems, but you didn't want to understand. Link to comment
Walid Posted May 1, 2015 Share Posted May 1, 2015 How we can help you if you dont want to show us your full codes? and the way that you reply us is so rude I was a bit angry because i have some problems, but you didn't want to understand. Bro how we suppose to know what is creating problem, you need to show us your full code because it's the only one solution. Link to comment
ALw7sH Posted May 1, 2015 Share Posted May 1, 2015 It's ok, can you explain what you want to do and show us your sql save/load codes? 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