We have developed a job-portal where users can view jobs and and also post jobs. We have used Php and MySQL. We hosted this on web faction. Now we want to develop the mobile app of the job portal for android, ios and windows. As the database should be synchronous and aligned dynamically with apps and website database. As the back-end code has to be changed to Java in android and c# in windows, how to manage a single synchronous database?

  • 3
    What makes you think that the back-end code needs to be changed in order to support a mobile app? Have you ever built mobile apps before? Do you know how they communicate with a server? – Carson63000 Dec 26 '12 at 22:17

You need a Service Oriented Architecture. Because you are sharing data across all those platforms, Web Services..

Basically rather that calling a "function" you make an HTTP request to a URL, parameters are passed in via the query string or Http header. XML or JSON is returned. Read up on it.

Thing is, your app need to be online at all times...

  • 1
    Thing is, your app need to be online at all times... - Well, that is, if you accept the OP's premise that the app must be "synchronous". – Jim G. Dec 26 '12 at 14:57
  • We have done this with php inline with html, input is taken through html. I tried getting values for android app by making http requets. The entire php is removed from the file and making http requests. Shoud the site be re-written again for easy base? I don't to write business logic again and again. Consistency is also an issue. – Abhishek Dec 29 '12 at 12:56

There are several ways to manage that.

At the lowest level, you can let the database server take care of it. If all applications connect to the same database on the same server and you correctly use SQL transactions, the MySQL server will ensure everyone sees a consistent view of the database.

But if you already need the internet connection to reach the database, why not have there a single web-server that manages the business logic together with the database access and returns the results in a format digestible for the various front-ends (android app, ios app, windows program, website). That way you only have to write the business logic once and only the front-end specific presentation code has to be written for each supported platform.

  • As it comes to business logic, the site has been done through php and html inline coding. Working on android, how can the same business logic stay? Even for ios or windows? – Abhishek Dec 29 '12 at 12:51
  • @user1696497: If the site does not have a clean separation between business logic and presentation code, you either have to replicate the business logic (multiplying the maintenance cost) or rewrite the site to have that separation and provide access for the other interfaces. – Bart van Ingen Schenau Dec 29 '12 at 17:23
  • Van: Thanks a lot for your advice. We will look to re-write the site for better maintenance. – Abhishek Dec 30 '12 at 18:13
  • Much of the logic can be taken care of in the DB level if OP goes for PostgreSQL - MySQL is not really designed for heavy DB level processing – Jit B Oct 22 '13 at 11:13

You need to make your php based web application 'service-oriented', i.e. it acts as a web service endpoint and only processes requests and responds with XML/JSON/text data. This interface will be available for use to both your mobile application and your web application (use ajax to communicate with the service).

In this case your web-application and mobile-application act as presentation layer for the data received from the web-service. However, because of how crawlers parse web sites, your ajax based web-application will not be readable by them. If you need your web-application to be readable by the crawlers then you need to introduce another layer that interacts with the web-service and presents the information as general HTML based page.

So your web app will be like:

Client >> Presentation-Layer (js) >[HTTP]> Service-Layer (php) >> DB (MySQL)


Client >[HTTP]> Presentation-Layer (php) >[HTTP]> Service-Layer (php) >> DB (MySQL)

if you want it to be parsable by crawlers.

And your mobile app will be like:

Client >> Presentation-Layer (java/obj-C) >[HTTP]> Service-Layer >> DB (MySQL)

You can also connect remotely to your main database from both the web application as well as the mobile application, but its not recommended form a security point of view, and you will also need to re-implement all logic on both the web and mobile application.

Not the answer you're looking for? Browse other questions tagged or ask your own question.