如何从 iPhone 连接到 MySQL 数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/468618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 12:40:34  来源:igfitidea点击:

How to connect to a MySQL database from an iPhone?

iphonesqlmysqlcocoa-touch

提问by Md Nasir Uddin

I am trying to connect to a remote mysql database from an iPhone. I have searched many web sites but I did not find any help. If anyone has worked with this please send a solution.

我正在尝试从 iPhone 连接到远程 mysql 数据库。我搜索了许多网站,但没有找到任何帮助。如果有人与此合作,请发送解决方案。

采纳答案by samvermette

Assuming you have some experience with server-side programming (like PHP or Rails), you could just create an NSArray from the content of a URL where you establish a connection to the MySQL server and print the results you want in ASCII or XML format.

假设您对服务器端编程(如 PHP 或 Rails)有一些经验,您可以根据 URL 的内容创建一个 NSArray,您可以在其中建立与 MySQL 服务器的连接,并以 ASCII 或 XML 格式打印所需的结果。

NSURL *myURL = [NSURL URLWithString:@"http://www.myserver.com/results.php"];
NSArray *sqlResults = [[NSArray alloc] initWithContentsOfURL:myURL];

Also useful to help you format the results printed by the server page: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html

也有助于您格式化服务器页面打印的结果:http: //developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html

回答by Oli

A quick googlewill show you the way...

一个快速的谷歌会告诉你的方式...