iPhone Application -> MySQL Connection

Hello!

I have been searching for the past week for a way to connect to a MySQL database from xCode.

My goal is to develop a simple iPhone Application that connects to a MySQL DB and performs CRUD operations (Create, Replace, Update, Delete).

It would be great if some of you can direct me to the proper documentation, or if this is actually impossible for the moment, I would like to know what would be the most suitable solution for an application that interacts with a server with PHP and MySQL.

Thanks in advance,
HT

MacBook Pro 15'', Mac OS X (10.6.4), Nothing

Posted on Jul 1, 2010 8:12 AM

Reply
3 replies

Jul 1, 2010 8:35 AM in response to horatiu.taina

The simplest is to create some simple web service wrappers (or http post handlers) that perform the MySQL operations. From the client you send messages (create message with text, update with text etc.). The web service can take care of the actual SQL interactions. This is no different from creating a proper MVC web application. In this case the view happens to run on the iPhone instead of in a browser.

Jul 1, 2010 12:30 PM in response to sptrakesh

Ok... Firstly, I would like to thank you for the prompt answer.

Let me know if I understood properly, please!

So, I am unable to connect directly to the MySQL database on my server from the iPhone application, but I can send messages/variables through POST (and my PHP server does it all - MySQL connection and parsing of the $_POST() array).

You are suggesting that every edit/update/replace... task should be sent through our very common two methods -> GET and POST.

Easy as it may seem, it is still unsafe. One can sniff the packages, and catch the data I transfer. And, besides, I might overload the server with this transmitted data and other operations back and forth.

At first, I was thinking of a much more efficient approach of the problem, and I was actually looking for something like a "MySQL Connect CONTROLLER", very similar to the well known PHP function/method mysql connect(server_variable,passwordvariable, ... ).

I am looking forward for your reply,
Thank you!

HT

Message was edited by: horatiu.taina

Jul 1, 2010 1:36 PM in response to horatiu.taina

http://discussions.apple.com/click.jspa?searchID=-1&messageID=11558485

As regards safety, raw MySQL socket connections are just as insecure as HTTP, and it is probably much worse to expose direct connections to MySQL from arbitrary clients (you can use SSL connections in either case to mitigate the risk). If you are afraid that client-server communications overload the server, you will have the same issue regardless of whether you make a direct connection or a web service connection.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

iPhone Application -> MySQL Connection

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.