从远程数据库中检索数据

时间:2022-12-04 16:29:40

could someone please explain to me the process of retrieving data from a remote database? I understand how to parse data from sqlite to an iPhone application however remote databases seem to be more complex. I tried to do research however i get confused about web services,clouds and other words that im not familiar with. So far i gathered that i need to use JSON to convert the data from the database into the appropriate format that is displayed on a php page? then the iPhone application connects to that page and retrieves the data?

有人可以向我解释从远程数据库中检索数据的过程吗?我理解如何将数据从sqlite解析为iPhone应用程序,但远程数据库似乎更复杂。我试着做研究但是我对网络服务,云和其他我不熟悉的单词感到困惑。到目前为止,我收集到我需要使用JSON将数据库中的数据转换为php页面上显示的相应格式?然后iPhone应用程序连接到该页面并检索数据?

Would someone be able to give me a brief explanation (also what database can be used with JSON? in this instance)? would me much appreciated (also if someone has any tutorials/articles about this would be grateful). Sorry if im totally wrong, trying to learn...

有人能够给我一个简短的解释(在这个例子中,数据库可以与JSON一起使用吗?)?我会非常感激(如果有人有关于此的任何教程/文章将不胜感激)。对不起,如果我完全错了,试着学习......

2 个解决方案

#1


3  

That are many ways to build a system where you have a client application that retrieves data from a "remote" system that runs a database. You have many many choices as to what the server runs, and what the client is... and there is a world of technologies involved in this...

这是构建系统的多种方法,其中您有一个客户端应用程序,它从运行数据库的“远程”系统中检索数据。关于服务器运行的内容以及客户端是什么,你有很多选择......而且这个技术涉及到......

Since you are interested in learning, I would suggest you to take into consideration a very common architecture for such systems and dig into it.

既然您对学习感兴趣,我建议您考虑一下这种系统非常常见的架构并深入研究。

One such example is LAMP (Linux, Apache, MySQL, PHP) and you can find a good tutorial at this site.

一个这样的例子是LAMP(Linux,Apache,MySQL,PHP),你可以在这个网站上找到一个很好的教程。

The tutorial covers everything you need, from setting up the systems, to retrieving the data and passing it back though the web; it's step by step and pretty easy to follow. The only thing that is not covered is JSON, but JSON in the end is just a format to pass data back and forth, and you can easily learn the basics about it with this tutorial.

本教程涵盖了您需要的一切,从设置系统到检索数据并通过Web传回数据;它是一步一步,很容易遵循。唯一没有涉及的是JSON,但JSON最终只是一种来回传递数据的格式,您可以通过本教程轻松学习有关它的基础知识。

Finally, I would suggest looking at how building an iPhone app getting JSON data. This would be the point where you join the two previous tutorials.

最后,我建议看看如何构建一个获取JSON数据的iPhone应用程序。这将是您加入前两个教程的重点。

#2


1  

  1. If you have a web service protocol on the server side, you can use JSON based web service to retrieve your data. If you follow any JSON tutorial, you can see JSON is just a text representation of the data.

    如果服务器端具有Web服务协议,则可以使用基于JSON的Web服务来检索数据。如果您遵循任何JSON教程,您可以看到JSON只是数据的文本表示。

  2. Or you can simply use a post request to your server, which can response by simple XML with your own defined tag. So that you can use NSXMLParser to parse the data in your iPhone and decode information from there.

    或者您可以简单地向服务器使用post请求,该请求可以通过简单的XML使用您自己定义的标记进行响应。这样您就可以使用NSXMLParser来解析iPhone中的数据并从中解码信息。

Any kind of database in the remote site will work. I prefer the free open source MySQL database.

远程站点中的任何类型的数据库都可以使用。我更喜欢免费的开源MySQL数据库。

With JSON web servie, you need some JSON converter for your database in the server side and also in the client side. A good open source client tool is SBJSONParser.

使用JSON Web服务,您需要在服务器端和客户端的数据库中使用一些JSON转换器。一个很好的开源客户端工具是SBJSONParser。

But if you use XML, you can define your own tag to encode and decode you database fields and information.

但是,如果使用XML,则可以定义自己的标记以对数据库字段和信息进行编码和解码。

#1


3  

That are many ways to build a system where you have a client application that retrieves data from a "remote" system that runs a database. You have many many choices as to what the server runs, and what the client is... and there is a world of technologies involved in this...

这是构建系统的多种方法,其中您有一个客户端应用程序,它从运行数据库的“远程”系统中检索数据。关于服务器运行的内容以及客户端是什么,你有很多选择......而且这个技术涉及到......

Since you are interested in learning, I would suggest you to take into consideration a very common architecture for such systems and dig into it.

既然您对学习感兴趣,我建议您考虑一下这种系统非常常见的架构并深入研究。

One such example is LAMP (Linux, Apache, MySQL, PHP) and you can find a good tutorial at this site.

一个这样的例子是LAMP(Linux,Apache,MySQL,PHP),你可以在这个网站上找到一个很好的教程。

The tutorial covers everything you need, from setting up the systems, to retrieving the data and passing it back though the web; it's step by step and pretty easy to follow. The only thing that is not covered is JSON, but JSON in the end is just a format to pass data back and forth, and you can easily learn the basics about it with this tutorial.

本教程涵盖了您需要的一切,从设置系统到检索数据并通过Web传回数据;它是一步一步,很容易遵循。唯一没有涉及的是JSON,但JSON最终只是一种来回传递数据的格式,您可以通过本教程轻松学习有关它的基础知识。

Finally, I would suggest looking at how building an iPhone app getting JSON data. This would be the point where you join the two previous tutorials.

最后,我建议看看如何构建一个获取JSON数据的iPhone应用程序。这将是您加入前两个教程的重点。

#2


1  

  1. If you have a web service protocol on the server side, you can use JSON based web service to retrieve your data. If you follow any JSON tutorial, you can see JSON is just a text representation of the data.

    如果服务器端具有Web服务协议,则可以使用基于JSON的Web服务来检索数据。如果您遵循任何JSON教程,您可以看到JSON只是数据的文本表示。

  2. Or you can simply use a post request to your server, which can response by simple XML with your own defined tag. So that you can use NSXMLParser to parse the data in your iPhone and decode information from there.

    或者您可以简单地向服务器使用post请求,该请求可以通过简单的XML使用您自己定义的标记进行响应。这样您就可以使用NSXMLParser来解析iPhone中的数据并从中解码信息。

Any kind of database in the remote site will work. I prefer the free open source MySQL database.

远程站点中的任何类型的数据库都可以使用。我更喜欢免费的开源MySQL数据库。

With JSON web servie, you need some JSON converter for your database in the server side and also in the client side. A good open source client tool is SBJSONParser.

使用JSON Web服务,您需要在服务器端和客户端的数据库中使用一些JSON转换器。一个很好的开源客户端工具是SBJSONParser。

But if you use XML, you can define your own tag to encode and decode you database fields and information.

但是,如果使用XML,则可以定义自己的标记以对数据库字段和信息进行编码和解码。