在iPhone应用程序的建议需要连接到远程MySQL [英] Advice on iPhone App needing to connect to remote MySQL

查看:117
本文介绍了在iPhone应用程序的建议需要连接到远程MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要并获取数据从MySQL数据库坐在一台服务器上连接。我已经成功地与 本地我的应用程序SQLite数据库,但是这是第一次我有一个 接口远程 的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.

我理解这个过程包括:

1)的iPhone应用程序发送该请求到服务器

2)一些API的被执行和执行实际的会说话的服务器上的数据库,然后返回查询结果作为XML(或JSON)

3)在iPhone然后分析返回的信息,并使用它然而它需要。

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.

我需要什么帮助是第2步 - 的API。我不知道PHP,我不知道PERL - 我真的要学习其中的一个只写一个API?我认为,这与iPhone到远程MySQL的任务将是司空见惯,以至于这样的API应该已经摆在那里,免费提供 - 但我没有真正看到任何东西。

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.

我知道的Objective-C真的很好 - 但我应该使用XML或JSON这个?我应该学习Perl或PHP?

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

任何提示或建议将是非常美联社preciated。

any tips or advice would be highly appreciated.

推荐答案

这是很难给你一个明确的答复不知道更多$ P $你在看pcisely什么,但它听起来像你的Web服务/ API部分应该是很轻。在这种情况下,它应该是很容易将它写在任何语言。如果你知道Objective-C的好,应该很容易上手一些PHP或Ruby。

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.

您提到的PHP和Perl。我用PHP看到的好处是,它可用在任何托管服务。例如,用PHP可以使MySQL查询在code几行

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.

否则,如果网络服务生活,你自己或者如果你有更多的灵活性,它可能更容易使用Ruby和喜欢的西纳特拉

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.

使用XML或JSON序列化数据对于,这将取决于什么类型的数据的API返回的。通常,JSON将简单得多和载体是在两侧好:
- 使用Ruby,你可以看到它是多么容易在这里使用JSON: http://flori.github.com/ JSON /
- 使用Objective-C中,你可以使用<一个href=\"http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html\"相对=nofollow> NSJSONSerialization 中开始提供iOS5的。

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.

这篇关于在iPhone应用程序的建议需要连接到远程MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆