简体   繁体   English

将PHP Web应用程序迁移到iOS

[英]Migrating PHP web app to iOS

So I've built a web app in PHP that relies heavily on a MySQL database. 因此,我用PHP构建了一个Web应用程序,该应用程序严重依赖于MySQL数据库。 Now (for user convenience purposes) I'm trying to create the exact same app, just as an iPhone app. 现在(为方便用户起见),我试图创建与iPhone应用程序完全相同的应用程序。 Granted, I have no knowledge of Objective-C (just starting to learn it), I wanted to know how to go about this. 当然,我对Objective-C并不了解(只是开始学习它),我想知道如何去做。 I know that I'll have to use some kind of intermediary to get Objective-C to connect to the SQL database. 我知道我将必须使用某种中介来使Objective-C连接到SQL数据库。

So essentially my questions are: If I've already created the web app as aforementioned, could I use the same DB and tables for the iOS app version as I did for the PHP web version? 所以从本质上来说,我的问题是:如果我已经如上所述创建了Web应用程序,那么我可以为iOS应用程序版本使用与PHP Web版本相同的数据库和表吗? Also, is there anyway to migrate any code I've created in PHP to iOS (I realize that they are two completely different languages), but I'm just curious as to whether or not I'll have to build the iOS app from 'complete' scratch. 另外,是否有将我用PHP创建的任何代码迁移到iOS的方式(我意识到它们是两种完全不同的语言),但是我只是好奇我是否必须从“完整”的划痕。

Your best bet is to write an PHP service to talk to your database. 最好的选择是编写一个PHP服务来与数据库对话。

This way you can share this API between your app or iOS app or any other type of client app. 这样,您可以在您的应用程序或iOS应用程序或任何其他类型的客户端应用程序之间共享此API。

The service will be responsible to receive request query the database and send responses in JSON format for example. 例如,该服务将负责接收请求查询数据库并发送JSON格式的响应。

So to make things easier, you should not query the database directly from your apps, use a common web service. 因此,为了使事情变得简单,您不应该直接从应用程序中查询数据库,而应使用通用的Web服务。

You can use your MySQL database for any purpose because it is just data. 您可以将MySQL数据库用于任何目的,因为它只是数据。 The code that will show them will be different though. 显示它们的代码将有所不同。 If you have no knowledge about Objective-C you should consider the web-app approach. 如果您不了解Objective-C,则应考虑使用Web应用程序方法。

Here are a few helper links. 这里有一些帮助链接。

https://developer.apple.com/library/safari/referencelibrary/gettingstarted/gs_iphonewebapp/_index.html http://gigaom.com/2010/02/12/how-to-create-an-iphone-web-app/ https://developer.apple.com/library/safari/referencelibrary/gettingstarted/gs_iphonewebapp/_index.html http://gigaom.com/2010/02/12/how-to-create-an-iphone-web-app /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM