Sync local mySql DB with Cloud mySql DB at a particular time intervel
I have a laravel application for a restaurant that the client wants the offline feature.
What we can do is host the application locally using phpdesktop and if the internet goes out the application should work and save the data locally.
When the internet comes back sync the new data to the live server.
Is any particular way I can do this? I have checked the SQL replication already. Any better solution to this problem?
@anand_aks just do it yourself. Whatever record in indexeddb that doesn't have an id has been created on the client while offline and needs to be saved to server DB.
@anand_aks Might be worth Googling when someone suggests something.
A PWA is a Progressive Web App. It uses a service worker under the hood. The user interacts with the web app, even if they’re offline. You can store things in a local database, i.e. IndexedDB. When you detect you have a network connection again, all the records in the local database can then be sent to the server using AJAX requests.
Also another option instead of worrying about syncing, simply have two databases. That way you don't run into having to deal with duplicates. Bear in mind if the internet is down, a customer can't order anyway, all has to be done locally in the restaurant. But just a suggestion.
At the time for reports, I.e., simply use data from both databases combined for income and expense reports, etc.
@jlrdw Keeping Multiple DB is not a good option for me. We have many branches and the network connection is not good. So we have to put the DB locally for each branch and these data need to sync with the single cloud DB so that the management can view all the different reports daily.