I'd like to query a MySQL database via a RESTful service with the middleware being PHP. I'd like the output to be JSON. I'm a beginner in those areas. Are there any frameworks or scripts that can do this without requiring you to be an expert? I don't have a problem stringing a few scripts together if they can work.
我想通过RESTful服务查询MySQL数据库,中间件是PHP。我希望输出为JSON。我是这些领域的初学者。是否有任何框架或脚本可以做到这一点,而无需您成为专家?如果它们可以工作,我就没有问题将一些脚本串在一起。
Or, if it can be done much simpler without using REST (i.e. query parameters), that's fine.
或者,如果可以在不使用REST(即查询参数)的情况下更简单地完成,那很好。
In the end, I want to have an iPhone app fetch this data and have it returned via JSON. No javascript will be involved.
最后,我希望有一个iPhone应用程序获取此数据并通过JSON返回。不会涉及javascript。
3 个解决方案
#1
2
You can convert a MySQL result set to JSON easily: http://phpclasses.nlared.com/browse/package/3195.html
您可以轻松地将MySQL结果集转换为JSON:http://phpclasses.nlared.com/browse/package/3195.html
For a RESTful interface, basically any hosted PHP script can function as a REST interface for your application.
对于RESTful接口,基本上任何托管的PHP脚本都可以作为应用程序的REST接口。
#2
1
Check out this project: http://phprestsql.sourceforge.net/
看看这个项目:http://phprestsql.sourceforge.net/
On this site you will find a RESTful interface (written in PHP) to a database (a MySQL database, but that's not important). Below you will find a interactive tutorial that will get you accessing, adding and deleting rows from our database via our Javascript powered REST browser.
在这个站点上,您将找到一个RESTful接口(用PHP编写)到数据库(MySQL数据库,但这并不重要)。您将在下面找到一个交互式教程,该教程将通过我们的Javascript支持的REST浏览器访问,添加和删除数据库中的行。
#3
0
The PHP shouldn't necessarily be your middleware in your situation, you'll have to build your "RESTful" service somehow, whether it be with PHP or any other language. You don't have to be an expert, but I think CakePHP has some of these capabilities.
在您的情况下,PHP不一定是您的中间件,您必须以某种方式构建您的“RESTful”服务,无论是使用PHP还是使用任何其他语言。您不必是专家,但我认为CakePHP具有一些这些功能。
Maybe explain in more detail what you want to do.
也许更详细地解释一下你想做什么。
Update
Try this out: http://techno-geeks.org/2009/08/easy-json-with-cakephp-and-jquery/
试试这个:http://techno-geeks.org/2009/08/easy-json-with-cakephp-and-jquery/
Not only is CakePHP easy to install and use, it's also easy to extend.
CakePHP不仅易于安装和使用,而且易于扩展。
#1
2
You can convert a MySQL result set to JSON easily: http://phpclasses.nlared.com/browse/package/3195.html
您可以轻松地将MySQL结果集转换为JSON:http://phpclasses.nlared.com/browse/package/3195.html
For a RESTful interface, basically any hosted PHP script can function as a REST interface for your application.
对于RESTful接口,基本上任何托管的PHP脚本都可以作为应用程序的REST接口。
#2
1
Check out this project: http://phprestsql.sourceforge.net/
看看这个项目:http://phprestsql.sourceforge.net/
On this site you will find a RESTful interface (written in PHP) to a database (a MySQL database, but that's not important). Below you will find a interactive tutorial that will get you accessing, adding and deleting rows from our database via our Javascript powered REST browser.
在这个站点上,您将找到一个RESTful接口(用PHP编写)到数据库(MySQL数据库,但这并不重要)。您将在下面找到一个交互式教程,该教程将通过我们的Javascript支持的REST浏览器访问,添加和删除数据库中的行。
#3
0
The PHP shouldn't necessarily be your middleware in your situation, you'll have to build your "RESTful" service somehow, whether it be with PHP or any other language. You don't have to be an expert, but I think CakePHP has some of these capabilities.
在您的情况下,PHP不一定是您的中间件,您必须以某种方式构建您的“RESTful”服务,无论是使用PHP还是使用任何其他语言。您不必是专家,但我认为CakePHP具有一些这些功能。
Maybe explain in more detail what you want to do.
也许更详细地解释一下你想做什么。
Update
Try this out: http://techno-geeks.org/2009/08/easy-json-with-cakephp-and-jquery/
试试这个:http://techno-geeks.org/2009/08/easy-json-with-cakephp-and-jquery/
Not only is CakePHP easy to install and use, it's also easy to extend.
CakePHP不仅易于安装和使用,而且易于扩展。