简体   繁体   English

将数据库下载到iPhone

[英]download database to iphone

The app I'm writing needs to get information from a remote database and then store it in the SQlite database on the iphone for offline use. 我正在编写的应用程序需要从远程数据库获取信息,然后将其存储在iPhone的SQlite数据库中以供离线使用。 As of now I'm using a php script to query the database and then just basically scrapping the html data from the php echo calls. 截至目前,我正在使用php脚本查询数据库,然后基本上只是从php echo调用中删除html数据。

My problem is that now that I'm moving away from test data I'm using database tables that are fairly large with complex dependencies. 我的问题是,现在我正在远离测试数据,我使用的是具有复杂依赖关系的相当大的数据库表。 I would really like to not to have to write a parser for these complex files to manually put the data and dependencies into the iphone database. 我真的不想不必为这些复杂的文件编写解析器来将数据和依赖项手动放入iphone数据库中。

My question is if there is any way to use a php script to pass to the iphone a copy the actual database file and then just dump that into the SQlite database on the iphone. 我的问题是,是否有任何方法可以使用php脚本将实际数据库文件的副本传递给iphone,然后将其转储到iphone上的SQlite数据库中。

While I'm not familiar with iphone development, it seems to me that you ought to be able to just construct the sqlite database file on the server, and then send it to the device (or have the device pull it down). 虽然我对iphone开发不熟悉,但在我看来,您应该应该能够在服务器上构造sqlite数据库文件,然后将其发送到设备(或让设备将其拉下)。 Of course, this is only efficient if you need to send the whole database every time. 当然,这仅在您每次需要发送整个数据库时才有效。

If you need to do things more incrementally (you're just adding some new data to the device's database) why not just have PHP write out SQL statements to make any necessary changes, send those to the device, and have the app execute them? 如果您需要做更多的事情(只是将一些新数据添加到设备的数据库中),为什么不只让PHP编写出SQL语句来进行必要的更改,将其发送到设备,然后让应用执行这些更改呢?

Make the serverss response XML and bring it into core data that way. 使服务器响应XML,并以这种方式将其带入核心数据。

http://code.google.com/p/touchcode/wiki/TouchXML will help you parse the response. http://code.google.com/p/touchcode/wiki/TouchXML将帮助您解析响应。

You could also make the server send its response in JSON and use this library, http://code.google.com/p/touchcode/wiki/TouchJSON 您还可以使服务器使用JSON发送其响应,并使用此库http://code.google.com/p/touchcode/wiki/TouchJSON

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

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