简体   繁体   English

如何将iPhone应用程序中的SQLite数据库中的数据发送到Web服务?

[英]How do I send data from SQLite database in iPhone app to Web Service?

I am creating an iphone app that will run an SQLite database. 我正在创建一个运行SQLite数据库的iphone应用程序。 I want the app to check, at start up, a MySQL database on a web server to see if there are new records. 我希望应用程序在启动时检查Web服务器上的MySQL数据库,以查看是否有新记录。 If there are the app will grab the new records. 如果有应用程序将获取新记录。

So I figure I have to identify the most recent record in the app then send that to a web service (php page) that will compare the id field from the most recent record in the app to the most recent id in the web server db. 因此,我想我必须确定应用程序中的最新记录,然后将其发送到Web服务(php页面),该服务将比较应用程序中最新记录的id字段与Web服务器db中的最新id。 If they don't match the web service will return the new records so the app can grab them and add them to the app database. 如果它们不匹配,Web服务将返回新记录,以便应用程序可以抓取它们并将它们添加到应用程序数据库。

I'll get the most recent record id using this query: SELECT id FROM MainTable ORDER BY id DESC LIMIT 1. But how do I then send the result to the php page to compare to the web database? 我将使用此查询获取最新的记录ID:SELECT id FROM MainTable ORDER BY id DESC LIMIT 1.但是,如何将结果发送到php页面以与Web数据库进行比较?

Here are the steps: 1) you need a web server with MySQL and PHP, if you do not have Web-Service for iPhone, then i would like to you refer 2) Make Web Service Call using NSURL (Make sure how you are calling the web-service). 以下是步骤:1)你需要一个带有MySQL和PHP的Web服务器,如果你没有iPhone的Web服务,那么我想你参考 2)使用NSURL进行Web服务调用(确保你是如何调用的)网络服务)。 you can use ASIHTTPRequest which is quite better than CFNetwork 你可以使用ASIHTTPRequest ,它比CFNetwork好得多

Notes : Write a PHP script that should returns JSON data which easy to parse. 注意:编写一个PHP脚本,该脚本应返回易于解析的JSON数据。 Use https (secure method) 使用https(安全方法)

Let us know if you have any issue.. 如果您有任何问题,请告诉我们..

为此我相信你必须实际编写一些代码 - 我不知道“罐装”解决方案。

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

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