Can I run PHP Scripts on iOS device? - php

I have an application that gets data from a SQL Server database using a PHP Script stored in an online server.
I get the data on my iOS app with NSURLConnection, I connect to the script and the script executes the queries on the server.
My question is, can I store this script on the iPhone or iPad and forget the online server?
Also, can I execute SQL Server queries without PHP Scripts and POST methods?

If your database is static(no update), then you can use iOS's native CoreData to manage the database locally and you dont need internet connection at all.
If your database needs to be updated after you release your application, then you will need a server.
In either case the programming language on iOS will be Objective C and C++ (instead of Python).

I was searching a lot of time for some library to do that I want. I found this library:
https://github.com/martinrybak/SQLClient
Main blog of the proyect:
http://objcsharp.wordpress.com/2013/10/15/an-open-source-sql-server-library-for-ios/
If you know another Libraries you can post in this thread for help the people with the same problem.
Regards.

Related

How to access sql server from Android the clean way?

On my project, I'm using a php site for getting data from sql server.
My android app connect the php site and send values , php site take values with POST method, and get the intended values from sql, after that, write in a html div(has an id), and last my app get data from html div with jsoup parser.
This way is working correctly, I'll ask about performance, when I Googled I saw a library called jdbc, so if I connect my app directly to sql server, is it get less loading time, or my way is true?
Sorry for my bad English :(
when I Googled I saw a library called jdbc, so if I connect my app directly to sql server
You can connect your app to sql server as long as sql server is accessible from Internet or your app has access to a network where sql server is accessible.
is it get less loading time
You can expect far better response time because you won't need the php site anymore as long as your JDBC code is well written.

Android web app - php with local database

I have a very simple web page in PHP that uses a MySQL database to randomly feed a simple quiz that goes on forever as long as the user wants to keep answering questions.
I want to move this to my Android to be able to use it offline. I used jQuery Mobile to adapt the layouts to the smartphone. So now I want to move the database to a local database and remove all the need to an internet connection. I have absolutely no experience on Android development so if anyone can help me with a few questions, I'd appreciate it:
How can I store my existing database in the smartphone?
The only actions that the app performs on the database are selects. The information on the database will grow with time (not much, I just want to be able to add more records with time). Is there any tool I can use to manage the local database and add the information as I need (as I do now with PhpMyAdmin)?
The web page exists online right now, will I be able to run it locally as it is? (aka, PHP page with css and js files)
Thanks in advance.
1) Android databases are done in SQLite. I'm unsure exactly what the syntax difference between mySQL and SQLite is, but if a straight dump/import doesn't work, you could export to csv/import that way. For info on getting an external database packaged with an app, check Using your own SQLite database with Android applications. It's a very helpful guide to getting it set up.
2) I use a Firefox add-on, SQLiteManager. I hate doing it, as it's the only reason I have Firefox installed any more, but on *nix it's the best option I've found. It's either that, command line, or SQLiteMan, which I found feature-lacking. On other platforms, I can't comment.
3) I don't know if PHP has a good library for SQLite. If so, you'll most likely need to do some modification to work with that instead of mySQL. If you can get that running smoothly, you should be able to drop it into a webview. The other option is to redo it in Java.
Good luck!

Using Adobe Air or Flex to connect to a server/php file for database interaction

I will be developing an smartphone app (eg iOS) in either actionscript 3 with adobe air or using flex. However I need to connect to a database for a huge amount of data storage and retrieval. There is a tonne of information about local database storage, but not on an external server!
I have done some research, most leads me to dead ends or not to be what I need. I have heard that its safer to pass variables to a PHP file which then deals with the database stuff; however how can I send data from the actionscript file over to a server and target php file? I cannot seem to find this anywhere!
At the moment I do not have an code to show, I am trying to find the best solution. Thank you.
I think the best is not to just call php scripts, but to build a php based webservice.
You can achieve that by using AMFPhp
Please check the links below on what you can do and how.
http://cookbooks.adobe.com/post_AMFPHP___Flex_4_demo-16508.html
http://polygeek.com/530_video-tutorial_amfphp-video-tutorial-connecting-to-amfphp-and-returning-data-version-10
http://www.silexlabs.org/amfphp/

Python sync with mySQL for local application?

There have been many questions along these lines but I'm struggling to apply them to my scenario. Any help would be be greatly appreciated!
We currently have a functioning mySQL database hosted on a website, data is entered from a website and via PHP it is put into the database.
At the same time we want to now create a python application that works offline. It should carry out all the same functions as the web version and run totally locally, this means it needs a copy of the entire database to run locally and when changes are made to such local database they are synced next time there is an internet connection available.
First off I have no idea what the best method would be to run such a database offline. I was considering just setting up a localhost, however this needs to be distributable to many machines. Hence setting up a localhost via an installer of some sort may be impractical no?
Secondly synchronization? Not a clue on how to go about this!
Any help would be very very very appreciated.
Thank you!
For binding Python to MySql you could use HTSQL:
http://htsql.org
You can then also query your MySQL DB via http requests, either from AJAX calls or server-side e.g. cURL (and of course still have the option of writing standard SQL queries).
There is a JQuery plugin called HTRAF that handles the client side AJAX calls to the HTSQL server.
The HTSQL server runs on localhost as well.
What OS would you be using?
How high-performance does your local application need to be? Also, how reliable is the locally available internet connection? If you don't need extremely high performance, why not just leave the data in the remote MySQL server?
If you're sure you need access to local data I'd look at MySQL's built-in replication for synchronization. It's really simple to setup/use and you could use it to maintain a local read-only copy of the remote database for quick data access. You'd simply build into your application the ability to perform write queries on the remote server and do read queries against the local DB. The lag time between the two servers is generally very low ... like on the order of milliseconds ... but you do still have to contend with network congestion preventing a local slave database from being perfectly in-sync with the master instantaneously.
As for the python side of things, google mysql-python because you'll need a python mysql binding to work with a MySQL database. Finally, I'd highly recommend SQLalchemy as an ORM with python because it'll make your life a heck of a lot easier.
I would say an ideal solution, however, would be to set up a remote REST API web service and use that in place of directly accessing the database. Of course, you may not have the in-house capabilities, the time or the inclination to do that ... which is also okay :)
Are you planning to run mysql on your local python offline apps ? I would suggest something like sqlite. As for keeping things in sync, it also depends on the type of data that needs to be synchronized. One question that needs to be answered:
Are the data generated by these python apps something that is opague ? If yes (i.e. it doesn't have any relations to other entities), then you can queue the data locally and push it up to the centrally hosted website.

Android connection to MySQL - Php or Servlet?

This is not a codefix question but please help me where possible.
I am developing an application which needs to store information in a database. This information needs to be stored off-device for security reasons (patient data).
I have explored using PHP as a bridge to the external MySQL database hosted locally via WAMP, however I have recently been informed of servlets and also of SQLite.
As I am learning these technologies under a limited time frame I need to know which to invest my time into to get the job done as easily as possible. I have no experience with any query language but I did get a simple login screen to work on Android using PHP and MySQL on WAMP using HTTP post/fetch within android.
Also, is it possible to store the information in SQLite within android and write that data to a server, which can then load the SQLite database again on re-launch?
Many thanks for your time!
From our expericence these kind of services need to work offline if possible. Both 3g and especially wifi has been unreliable in several occasions.
You do good if you save the data locally in e.g. sqlite database but be warned the data can get wiped on OS update or software update.
Also try to write your changes/additions in batches and servr updater can send all the batches that are not yet on the server. this way it's more reliable if you miss updates.
These kind of interfaces to another systems take a lot of time in testing. Consider getting a new timeframe in advance.
You will find more about Android connection to MySQL here

Categories