与PHP结合使用Web服务的Andr​​oid远程MySQL业务业务、Web、PHP、Andr

2023-09-05 00:59:14 作者:皮卡没有丘

我了解如何通过机器人连接到远程MySQL数据库一些不错的文章。 发现了一些非常有趣的链接这里和的此处。 所以用于获取数据的常见方法似乎是使用某种web服务的(接口,在这种情况下,PHP脚本),该查询分贝和呈现结果以JSON(或XML)格式。然后,它可以解析的Andr​​oid JSON_Object实现此输出。到目前为止好。 从数据库中接收数据并显示它在一个Android的列表视图在大约几分钟完成。

I read some nice articles about how to connect to a remote MySQL database via Android. Found some really interesting links here and here. So the common way for getting data seems to be using some kind of webservice (interface, in this case a php script) which queries the db and renders the result in JSON (or XML) format. Then its possible to parse this output with the android JSON_Object implementation. So far so good. Receiving data from the database and showing it up in a android listview was done in about minutes.

但是,什么是写(插入)数据到表中的最佳实践? 如果一个Web服务用在这里呢? (或者说直接的mysql康涅狄格州) 什么是数据推到一个web服务的最佳方法是什么? (为前。插入在一个数据库中的新实体)和应使用哪种格式问题 在这种情况下,我不使用任何HTML表单或任何张贴的参数。因此,如何发布这些参数的PHP脚本? (来自内部的Andr​​oid应用程序!) 当然,这种操作应该是安全的为好。实现数据操作机理是多一点冒险(为了保持分贝持续性)

But what is the best practice for writing (inserting) data into tables? Should a webservice be used here too? (or rather direct mysql conn) What is the best method to push data to a webservice? (for ex. to insert a new entity in a database) and which format should be used? In this case I do not use any html forms or anything to post the parameters. So how to post these parameters to the php script? (from within the android app!) Of course this operation should be secure as well. Implementing a data manipulation machanism is bit more risky (in order to keep the db persistant)

我认为,许多应用程序使用某种数据库中,同步数据(例如:高分)。 所以应该有一个最佳实践。

I think, that many apps use some kind of DB, to synchronize data (ex: highscores). So there should be a best practise for that.

推荐答案

我会建议保持任何特定数据库的背后隐藏着一个Web服务。

I would recommend keeping anything database-specific hidden behind a web service.

如果你建立MySQL的依赖到你的应用程序,后来发现你需要更改的数据库,整个安装基础已经被削减了。想想完成了几分钟,你就会开始认识到这是一个噩梦的后勤工作。

If you build a dependency on MySQL into your application and later find that you need to change databases, the entire installed base has to be cut over. Think about the logistics of accomplishing that for a few minutes and you'll start to realize it's a nightmare.