0

I'm developing an app for Firefox OS and I need to retrieve/sent data from/to my DB. I also need to use this data in my logic implementation which is in JS.

I've been told that I cannot implement PHP in Firefox OS, so is there any other way to retrieve the data and use it?

PS: This is my first app that I'm developing, so my programming skills are kind of rough.

3 Answers3

0

You should hold on the basic communication paradigms when sending/receiving data from/to a DB. In your case you need to pass data to a DB via web and application.

Never, ever let an app communicate with your DB directly!

So what you need to do first is to implement a wrapper application to give controlled access to your DB. Thats for example often done in PHP. Your PHP application then offers the interfaces by which external applications (like your FFOS app) can communicate with the DB.

Since this goes to very basic programming knowledge, please give an idea of how much you know about programming at all. I then consider offering further details.

Ahab
  • 676
  • 1
  • 7
  • 15
  • What you explained is exactly what I had in mind, but as a first time app developer, my skills with PHP is not all that great. I'm fine with JS but that's pretty much it. – Achyuth K P Feb 26 '15 at 13:11
0

You can use a local database in JS, e.g. PouchDB, TaffyDB, PersistenceJS, LokiJS or jStorage.

You can also save data to a backend server e.g. Parse or Firebase, using their APIs.

Or you can deploy your own backend storage and save data to it using REST.

niutech
  • 28,923
  • 15
  • 96
  • 106
  • I've been told that the 3rd option you mentioned is best way to go. its just that, I'm not entirely sure how to go about it. PS: This is my first time developing an app, so most of this is kind of confusing. – Achyuth K P Feb 26 '15 at 13:09
  • I'm actually trying out Firebase, but it seems that it doesn't work when I use both localStorage and Firebase at the same time. I'm trying to find a way to fix that. – Achyuth K P Mar 08 '15 at 08:49
0

It might be a bit harder to do than you expect but it can be easier than you think. Using mysql as a backend has serious implication. For example, mysql doesn't provide any http interfaces as far as I know. In other words, for most SQL based databases, you'll have to use some kind of middleware to connect your application to the database.

Usually the middleware is a server that publish some kind of http api probably in a rest way or even rpc such as JSONrpc. The language in which you'll write the middleware doesn't really matter. The serious problem you'll face with such variant is to restrict data. Prevent other users to access data to which they shouldn't have access.

There is also an other variant, I'd say if you want to have a database + synchronization on the server. CouchDB + PouchDB gives you that for free. I mean it's really easy to setup but you'll have to redesign some part of your application. If your application does a lot of data changes it might end up filling your disks but if you're just starting, it's possible that this setup will be more than enough.

Loïc Faure-Lacroix
  • 13,220
  • 6
  • 67
  • 99
  • Yeah I found out that it isn't exactly a cake walk to create the middleware for connecting the application and the DB. So, I'm actually trying out Firebase as my mobile backend. But I'll try PouchDB if it doesn't work. Thanks a lot. – Achyuth K P Mar 08 '15 at 08:46