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

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

问题描述:

我试图从iPhone连接到远程mysql数据库。我搜索了很多网站,但我没有找到任何帮助。

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.

假设你有一些服务器端编程的经验Rails),你可以从一个URL的内容创建一个NSArray,在那里建立到MySQL服务器的连接,并以ASCII或XML格式打印你想要的结果。

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.

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

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

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