Reputation: 1700
I've been creating a mobile web app wich has a MySQL database back-end and some simple PHP fetch querys to get SQL datasets and put them into an array for further processing with JavaScript.
Right now, everything is built in one file called index.php.
What would be the best practice, to make the site offline compatible. The SQL Data needs to be stored into the local storage with HTML5 somehow and I would probably need to separate the PHP code into an own file and include the query with AJAX, right?
Are there any code examples for that?
Upvotes: 2
Views: 684
Reputation: 1027
You might take a look at BreezeJS. It has support for MySQL and greatly simplifies managing JSON data offline. You load the data as JSON, which BreezeJS saves in its EntityManager and then you can serialize the data and save it into local storage. It's very fast and very simple to use once you work through a few examples
var exportData = manager.exportEntities();
window.localStorage.setItem('myOfflineData', exportData);
Upvotes: 1