0

I am looking for a tutorial on how to make an iPhone app that fetches data from and writes data to a MySQL database. I've seen some other threads saying that I should make an abstraction layer so as not to connect directly to the database from my app, but I'm not sure of how to actually go about doing this. Does anyone know of any tutorials that involve creating an abstraction layer for a MySQL database or connecting a MySQL database to an iPhone app?

To clarify, I am looking for a secure method that wouldn't allow people to sniff out my MySQL host, username and password. It seems like the libraries that connect directly to MySQL from the iPhone all have this problem, but please correct me if I'm wrong.

6 Answers 6

2

This is a really good tutorial that covers how to communicate with MySQL from an iPhone app using PHP:

http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app

Sign up to request clarification or add additional context in comments.

Comments

2

I know only one library, which makes possible connection from iPhone to MySQL. This is port of official MySQL C libraries created by Karl Kraft.
Author published also small portion of samples, which describes how to use this library.

UPDATE (Karl Kraft's broken link)

Instead of link above, I used an archived copy.

2 Comments

Thanks, but I read on the sample page that connecting to MySQL directly from the iPhone would allow someone to sniff out your database admin information, which doesn't seem very secure. Do you know any way of actually making this method secure?
do you have a copy? the link is down
2

not up to date, but this tutorial helped me a lot: http://codewithchris.com/iphone-app-connect-to-mysql-database/#connectiphonetomysql

Comments

0

Here http://blog.iosplace.com/?p=30 is a snippet that uses the original mysql client lib, and here http://www.karlkraft.com/index.php/2012/01/ is a link to a 3rd-party connector.

Comments

0

Here is a nice tutorial on how to connect to a database using web service layer. From a practical perspective you could connect directly to a database from an iphone because that is a client server transaction. The problem is that you would need to expose your database server an issue that many would find very disturbing, because you would expose your server which hold your most valuable resource "your data". Of course you can implement and could be a good solution for rather small projects. But you would need to implement the layer which it would be used to connect on the iOS app, adding more complex to the matter.

Using a web service is more reliable even from the iOS developer, because there is a very extensive api for using web service, which offer great functionality (asynchronous transactions, threads management,JSON Mapping, XML Mapping) to name a few.

Comments

0

Use the library OHMySQL. It copes with MySQL through MySQL C API. enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.