简体   繁体   中英

Best practice for offline compatibilty of mobile web app using MySQL and PHP

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM