0

I'm developing a PHP application using the CakePHP framework. It has a blog type format and I was wondering if there was a way to save data from a collection of posts for offline usage.

To give an example, if a user likes a post and thinks they might be able to use in situations were they are offline, then there would be a save this post button that saves the post data to their local device for later use when they have no network connectivity.

Anybody got any suggestions? TIA.

jpayne
  • 102
  • 2
  • 9
  • might be helpful http://stackoverflow.com/questions/371875/local-file-access-with-javascript – andrew Oct 22 '14 at 10:04
  • Do you really want to store raw SQL code in the client and then happily run whatever comes back? That's like going on vacation and leaving your front door wide open with a sign that says "out till November, leave mail on kitchen table, please don't steal my plasma TV". – Álvaro González Oct 22 '14 at 10:11

1 Answers1

2

You obviously did not try to use Google:

See http://www.html5rocks.com/en/features/storage

Offline Technologies:

  • Web Storage simply provides a key-value mapping, e.g. localStorage["name"] = username;. Unfortunately, present implementations only support string-to-string mappings, so you need to serialise and de-serialise other data structures. You can do so using JSON.stringify() and JSON.parse().
  • Web SQL Database gives you all the power - and effort - of a structured SQL relational database.
  • Indexed Database is somewhere in between Web Storage and Web SQL Database. Like Web Storage, it's a straightforward key-value mapping, but it supports indexes like those of relational databases, so searching objects matching a particular field is fast; you don't have to manually iterate through every object in the store.
  • File Access is an API for reading file content in JavaScript. Given a set of files the user has added to a "file" input element, you can read the content of the file or reference it as a URL, e.g. if the user has specified an image file, you can show the image. There are also proposals underway for file writing capabilities.

For a detailed comparison of client-side storage techniques with code demos, see our Client-Side Storage article.

floriank
  • 25,546
  • 9
  • 42
  • 66