如何从iOS应用程序访问服务器MySQL数据库 [英] How to access server MySQL database from iOS app

查看:741
本文介绍了如何从iOS应用程序访问服务器MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 Xcode 写一个 iOS 应用程式。

I'm trying to write an iOS app using Xcode.

一个简单的登录提示用户名和密码。

A simple login prompting username and password.

我不知道如何打开数据库连接来验证用户名和密码。

I have no idea how to open a database connection to validate the username and password.

我使用的数据库是 mysql

我尝试使用此链接 http:// macbug.org/macosxsample/mysql#.Ur8AYBbtGPF

但我收到一个错误,当我试图添加 libmysqlclient.a 到框架和库。

but I get an error when I tried to add libmysqlclient.a to the frameworks and library.

推荐答案

如果您的数据库位于某个服务器上,那么您通常不会让iOS应用程序与数据库服务器直接交互,而是你将写一个应用程序将与之交互的Web服务(通过 NSURLConnection NSURLSession 或类似 AFNetworking ),并且Web服务将与MySQL数据库进行交互。

If your database is on a server somewhere, then you would generally not have your iOS app interact directly with the database server, but rather you would write a web service that the app would interact with (via NSURLConnection, NSURLSession or something like AFNetworking), and the web service would interact with the MySQL database.

在编写Web服务方面,通常,当人们编写他们的第一个Web服务时,他们将使用一些简单的技术,如PHP。你知道你的服务器上有什么选项吗?如果PHP是一个选项,那么你可以查看Ray Wenderlich的如何编写一个简单的PHP / MySQL Web服务。然后查看如何编写使用网络服务的iOS应用

In terms of how to write a web service, often, when people are writing their first web service, they'll use some simple technology like PHP. Do you know what options you have on your server? If PHP is an option, then you can check out Ray Wenderlich's How to Write a Simple PHP/MySQL Web Service. Then check out How to Write an iOS App that Uses a Web Service.

这篇关于如何从iOS应用程序访问服务器MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆