sirab333
sirab333

Reputation: 3722

Advice on iPhone App needing to connect to remote MySQL

My App needs to connect to and grab data from a MySQL database sitting on a server. I've successfully interfaced with local SQLITE databases in my Apps, but this is the first time I've had to interface with a remote MySQL database.

I understand this process involves:

  1. the iPhone App sending this request to the server
  2. some sort of API gets executed and it does the actual "talking" to the Database on the server, and then it returns the query results as XML (or JSON.)
  3. the iPhone then parses the returned information and uses it however it needs to.

What I need help with is step # 2 - the API. I don't know PHP, I don't know PERL - do I really have to learn one of these just to write an API? I thought that this iphone-to-remote-MySQL task would be so commonplace that such API's would already be out there, available freely - but I'm not really seeing anything.

I know Objective-C really well - but should I be using XML or JSON for this? Should I be learning PERL or PHP?

Any tips or advice would be highly appreciated.

Upvotes: 3

Views: 1144

Answers (2)

Puran
Puran

Reputation: 994

Well you can talk to remote MySQL server using Objective C client directly from iphone as show here

Upvotes: 0

Kamchatka
Kamchatka

Reputation: 3675

It's hard to give you a definite answer without knowing more precisely what you are looking at, but it sounds like your web service/API part should be quite light. In this case, it should be quite easy to write it in any language. If you know Objective-C well, it should be very easy to pick up some PHP or Ruby.

You mention PHP and Perl. The good thing I see with PHP is that it's available on any hosting service. For instance, with PHP you can make MySQL queries in a few lines of code.

Otherwise, if the web service lives on a machine that you own or if you have more flexibility, it might be easier to write something using Ruby and a small framework like Sinatra.

Regarding using XML or JSON to serialize the data, this will depend on what type of data your API returns. Generally, JSON will be much simpler and the support is good on both side: - With Ruby, you can see how easy it is to use JSON here: http://flori.github.com/json/ - With Objective-C, you would use NSJSONSerialization available starting with iOS5.

Upvotes: 1

Related Questions