-1
I have a JSON database of users, for example, if I update my username via AJAX POST, click update and call AJAX exchange the value based on my ID with PHP, all right.
Ai enters the doubt in PHP processing I give overwrite in the bank, ie, save it on top of the other replacing.
In a real demand of hundreds of users updating the username at the same time in the same JSON database and possible bugs?
In SQL you have Sqlquery that avoids bugs (I think) but in JSON databases what would be the smartest way to use?
Only process this overwhite after the user closes the page? thus processing the database update only once instead of every time you click update some data call AJAX immediately?
JSON is an encoding format, not a database. You’re writing JSON to a file on the server, is that it? I think the natural way is to migrate to a Nosql database that represents the data in a hierarchical way, very similar to JSON.
– epx
Use JSON as the same database, in php dou file_get_contents('arquivojson') and store in a variable then json_decode changes the values coming from the front and saved again with json_encode and file_put_contents('arquivojson');
– Eder Leandro
I know maybe it’s not the best way, and just a doubt!
– Eder Leandro
In the case of multiple requests at the same time of a file_put_content() saving the same file, as PHP would behave?
– Eder Leandro
I’m sure it’ll give M. At best, if two or more lawsuits write the file, only one survives. If everyone was making changes, only the change of the lucky process survives.
– epx
I can not understand when the staff negative these questions, he IS BEGINNER, do not know what works, if the site was for people 100% experienced, there would be no questions and answers. My opinion...
– Leonardo Bonetti