Master data and MySQL

How do I create a data engine application that syncs with a MySQL database?

Should I implement a SQL-Lite layer and try to sync with MySQL this way?

Or will web services perform better? However, I want to use Core Data Modeling.

Can Linq be used? I love linq.

+2


source to share


4 answers


If you are using CoreData, you are not accessing its underlying storage directly (except for implementing custom atomic stores). If you want to sync with MySQL, you need to access the MySQL database (either directly through libmysql or through the application server) and then merge that data into managed objects.

In other words, your CoreData model is completely local and you only need to access it through the CoreData API. How you get the data in and out is a completely separate issue, and the fact that the underlying storage might be sqlite has nothing to do with it.



And no, there is no way to use LINQ on the iPhone. My guess is that at some point in the future this may be possible via MonoTouch, but unless you are writing a complete MonoTouch application, I suspect that marshaling objects back and forth would be very unnatural with Objective-C code.

+3


source


I am a PHP / MySQL programmer in my day job and the easiest way I could get data from MySQL for my Core Data application is to make an HTTP connection to a PHP webserver which returned the data in plist xml format. Then I can easily populate the NSArray using the plist data.

For example, this is how I did it in my application:

NSURL *url = [NSURL URLWithString:@"http://myphpwebsite.com/products"];
NSArray *products = [[NSArray alloc] initWithContentsOfURL:url];

      



Then I had the NSArray of the products that I was using in my application and saved to Core Data.

I always recommend that people use PHP, Apache and MySQL together. They work great together on the backend with almost no problem. For example, I can easily get data from MySQL using PHP. I can then manipulate this data in PHP in the xml plist format used by my iPhone application.

+5


source


I have some code to sync core data with any database on the server. It uses a web service and communicates via JSON. Not only is he not database agnostic, but he doesn't care if the data structures are different.

It will be included in the next version of the QuickConnectFamily framework. http://www.quickconnectfamily.org

Let me know if you need the code before releasing .a

+2


source


Also check out Restkit.org I pointed to it when I asked a similar question (but I'm using Core Data) and it looks very promising!

+1


source







All Articles