My plan is to store data in my local MySQL database and after a time interval it will update my live MySQL database remotely. Is it possible?
I'm planing a inventory management script in PHP MySQL. The real problem is in our country net connection drops suddenly. So I want to first write to the local MySQL database and then it will update the real server. In any situation like internet connection dropped the script will work locally to gather data and retrieve data. When the internet connection comes back it will update the data to the real server. I want to protect against internet connection failures.
Nothing will update the real server in the mean time because the users are only in the office where the internet connection will drop. No one from the outside will able to update the database. Only the information can be retrieved from the live server to the shop's owner.
Best Answer
Hello you can sync your local database data with your live mysql server. I had done it making a local sync file that will present all the tables of the local database that I wanted to update to live database and then calling a call back function in footer file that function calls the function to sync local data to live server
Footer.php
Config.php
sync.php contents Also you need to on CURL extension in local site wamp so that it can communicate with the server side, If database record that is already synced to server edited then sync field in DB should be set to 0 so that on edit it can overwrite server DB again.
Sync.php
Then after that you need to make a controller on live server I named it sync_server.php
sync_server.php