Load data from a MySQL database to an Objective C/XCode Project - mysql

I have a simple question to XCode/iOS developers out there. I just want to know what are the most basic ways of fetching/inserting data into a MySQL database from an Objective C/XCode program. Basically, what I am planning to do is to create a mobile application version of the website I am currently developing. In short, the XCode program I'm planning to do is a way smaller version of a PHP web application. The XCode program will be able to modify, insert, and fetch data from the database of the website.
Can you guys give me a hint? A tutorial (or links)? I'm not even a new XCode developer, I'm only about to begin being one for the capstone project I am developing with my group (I'm in college, if this info is even necessary LOL).

You should do :
Implement a sever API (Web Services) with your preferred language ( PHP,...) that can communicates with the Data base.
An objective C client ( iOS application) that communicates with the data base but using your API ( Web Services).
here are excellent tutorials that will show you how to do all the steps. Tutorial

I would use REST webservice:
Write a piece of code with XCode which do HTTP GET and HTTP Post to your server. Query data with GET and Insert Update delete with POST.
After this write your server side code in PHP , Java, whatever you know / like to receive those 4 operations, connect to database and send a result you.
This architecture is used in many mobile applications.
Has some Pro and so Cons, like everthing.
The Pro:
separated code connection to database, separated units => improved security. Probably you don't want everybody see your mysql root password... who can decompile the iPhone app.
With separated client-server: it allowed multiple connections, caching.
The list is very long here.
The cons:
Probably need to know 1 more developing language than Objective -C
Need web hosting, not only database hosting
The list is a lot shorter here and less important.

Related

Secure Database Connection in ElectronJS Production App?

I've recently begun developing with NodeJS and ElectronJS to create some pretty nifty cross platform software. I want to take it a step further and integrate some database functionality.
While I'm aware that there are mysql packages available to install, I cringe at the idea that anybody can just unpack my asar.app file and see all of the connection details, including username, password, database name, table name, and other sensitive content that you really don't want to expose to people clever enough to break into your app's source code.
I've tried searching extensively on solutions to this problem, which I was surprised to find very little about. How do WhatsApp and Slack secure connections to their database if they were also built with ElectronJS?
Any and all resources are greatly appreciated. I basically want to be able to connect to a production server SQL database in an ElectronJS app without leaving some security backdoor to anybody who cracks the ASAR file.
Thank you!!
For this scenario, I suggest you to use a RESTful web service architecture. Basically you need 3 component, RESTful web back end, client application(your electron) and the database service( see the following image ; source:phppot.com) .For this I suggest you to use nodeJS backend and create a webservice using expressJS . You can define Restful (GET, POST,UPDATE, DELETE) API for each services.
For ex: To get some data from your db, you can send a GET request to the following path <yourdomain>:<port>/api/v1/getyoursomthin using your electron app. Your express app process the request and get the relevant data from the data from the database (Tutorial). So your app can get the respond from the server and display to the user. I will add link to some tutorials. You can find and learn more by google :)
Web: Build a simple app using Node JS and MySQL.
Express.js Tutorial: Build RESTful APIs with Node and Express
( source:phppot.com)

iOS and Mac OSX communicating with MySQL database

I have a client who wants a control panel for the app I am developing them. The control panel is a Mac OSX application that allows the user to submit files (excel docs and such) to my MySQL database. Those files are then checked by the iOS app I have created for them.
I have no idea how to do this. I have the MySQL database all set up, and I have looked everywhere for a solution. Any help is appreciated.
I wouldn't try to connect to your MySQL database directly from your cell phone. It's a bad design for several reasons. Instead build a API on the same server as the MySQL database. It doesn't matter if you do it in java, php, c# or anything else. You might even find some product or open source project that can do this automatically. I've listed some benefits of doing it this way
It makes testing easier. You can write a test framework against your API that doesn't rely on or is using a phone.
It makes development faster. You don't need to emulate or use a phone to develop and test your table design and queries.
It gives you compatibility. When you need to change your database (and you do) you can create new APIs that the new version of the app uses while and old version still out there can continue to use the old API (that you might have to modify to still provide the same functionallity)
It gives you flexibility. If your user base grows and you might need to have replication for reads or sharded databases you build that into the API instead of into the app which is just a better way to do it.
One option would be to use PHP to handle all the database interaction.
Host the scripts on the server and just have the apps call them and get the scripts to return some sort of parseable response (I'd go for JSON).
I have never found a suitable Object-C based connector for MySQL. At this point I would suggest using a C/C++ connector. There's lots of examples of how to configure the connector for both C and C++. The hard part will be all of the data passed from the MySQL code and the Object-C code will that it will have to be in C types.
EDIT: An Example

Desktop programming language to connect to remote MySQL

A customer of mine asked me a better and faster solution to update it's real estate web site as he and his employees don't want to connect to the web site and update one by one the ads as they don't want to loose time waiting the normal latency of the internet.
I firstly solved the issue by building a PHP script that imported an Excel file into the web site's MySQL database and it worked greatly. But the problem were pictures that have still to be uploaded separately. I then wrote a PHP script that uploaded the pictures using ajax and drag&drop so the user could select multiple pictures and upload them at once. And this worked too, but the customer is still not completely satisfied as he says this solution is quite 'patched'.
I then thought about a desktop application - a kind of local database (could be SQLite) - that the user keeps updated locally and only at the end of the day the app connects to the remote server and updates the db and uploads the pictures.
My question is: what EASY desktop high level programming language I could use to do the job? Do you know any RAD (visual IDE) programming language able to connect to a remote mySQL server and upload data via a simple custom GUI?
I tried RealBasic and PureBasic but I did not work it out. I thought about building the app in PHP and then convert it to EXE but I did not tried yet.
Please don't suggest me Java, C or Delphy as I'm looking for something very easy.
Thank you
Have you considered a client side javascript/html app that syncs with the server, since you're already familiar with the platform? If one browser better supports what you want to do (Firefox has some extension perhaps vs Chrome, or whatever), than mandate that to run this app (rather than worrying about being portable across browsers).
All of the browsers can have client side storage now, and you can just do things locally, and finally push them to the server "all at once".
If your client is using a Windows platform, you could use IronPython (.NET), VB.NET, or C#. These all allow you to create windows/forms visually in Visual Studio. If you're not already familiar with the .NET platform I'm not sure how 'easy' this will be, but I think that's going to be true for most other platforms as well.
That being said, it sounds like your existing solution is probably the best idea - perhaps if you can make your solution feel less like a "patch" they will be satisfied.
No reason you can't use Purebasic if that's what you're comfortable with. There are HTTP file upload examples on the PB forums.
I've used Purebasic for years but I'd recommend spending the time to get to know C#/.NET - it's a world of difference and once you learn it stuff like this is pretty easy.

Develop an iOS App that gets contents from a remote DB

I am developing an education app for Kids.
The application is going to contain pictures, stories and video as well.
Including all above contents in the app will surely bloat it and hence i would like store all data on a server that will be accessed by my app.
I haven't used any remote databases (like MySQL or Oracle) with any other iOS app. In fact i am a newbie in developing such kind of apps. Can any one point me to a sample
Connecting to a remote mysql is really not recommended.
The security here is critical.
You should create a webservice and my advice to you is to make sure that the access to the webservice is restricted
The webservice can be your own "protocol" or any other well known protocol like SOAP
By your own I mean, json, csv .... or whatever.
Edit 1
The technology of your webservice should be dependent on many things.
If the system is small, and the code needs to be update very often, I would suggest to do it with PHP and some small(!) MVC framework like CI.
But if its a large system with needs of ACL (access control list) I will probably choose java with spring...
I suggest that : Do not connect to / use database directly from user application. It may causes serious security problems and your app should have native SQL drivers to connect db.
So, create a web service that receive queries from the application and response in XML, JSON or some other strings that easy to parse. This will be much easier than embed native APIs into your apps.

Interface between CardDav server and MySQL database

My web app uses mysql to store contact data. I'd like to sync this data via carddav with mobile devices. I understand carddav is based on a file system, not a database. What software is available to act as an interface or wrapper to make the carddav server work with mysql? or other relational database?
You might want to take a look at Bedework.
Baikal just added this feature!!!
Most dav servers are file system based. If you use SabreDav you can build a virtual filesystem based on your own backend. Baikal is a project that uses sabredav, and a virtual file system. Until recently it stored its data in sqllite. Now it supports both mysql and sqlite.
Its still not 100% mature, but its a great starting point. Playing around with it, I have been able to create contacts directly in the DB (by uploading vcard blobs to a table) and then having them show on my ipad addressbook.
After evaluating many systems, ones built on sabredav like baikal tend to be the simplest to build on. Fruxx is something else you may also check out. Its a hosted system, but will soon have an api.
Last if you are looking for a very elaborate system, then take a look at tine20. It supports activesync (illegally in the usa), carddav, caldav, and has a decent extjs web ui. It natively stores contact information in its mysql store, which is nice since you can update a contact through a sql statement without having to build a vcf file. Where tine doesnt make sense is that it uses a bit more resources because of all the features it offers, and the complexity has ensured that it has a VERY complicated database schema. In other words, you are probably better off creating a rest api on the tine source code rather than doing bare sql inserts.
http://baikal-server.com/