views:

66

answers:

3

The app I'm writing needs to get information from a remote database and then store it in the SQlite database on the iphone for offline use. As of now I'm using a php script to querry the database and then just basically scrapping the html data from the php echo calls.

My problem is that now that I'm moving away from test data I'm using database tables that are fairly large with complex dependencies. I would really like to not to have to write a parser for these complex files to manually put the data and dependencies into the iphone database.

My question is if there is any way to use a php script to pass to the iphone a copy the actual database file and then just dump that into the SQlite database on the iphone.

A: 

While I'm not familiar with iphone development, it seems to me that you ought to be able to just construct the sqlite database file on the server, and then send it to the device (or have the device pull it down). Of course, this is only efficient if you need to send the whole database every time.

If you need to do things more incrementally (you're just adding some new data to the device's database) why not just have PHP write out SQL statements to make any necessary changes, send those to the device, and have the app execute them?

timdev
Well allow me to clarify a bit then. I need to get very large chunks of the database to do what I need to do. So incrementally is out of the question. I would love to just be able to dump a SQlite database on the iphone but thats exactly what I'm trying to ask about. How can I take a remote database and use a php script to move it to an iphone?
E. Criss
I don't see why not. Again, I can't answer on the iphone side, but I'd be surprised if you can't grab a file via HTTP and stick it somewhere on the device for use. On the PHP side, you could just construct the sqlite file, and stick it in some web-accessible directory, then have the phone app fetch it. If you're worried about having the file publicly available, you could have a PHP script that passes the data along using readfile(), after making sure the client in question is authorized to grab the data file.
timdev
Again that is what I'm asking. What do I need to do and what commands can I use to actually download a database file
E. Criss
Maybe this answer contains a good pointer: http://stackoverflow.com/questions/2066165/how-to-download-large-files-using-objective-c-on-iphone
timdev
if that answer's not right, try searching SO for "iphone download file". Another answer that looks promising: http://stackoverflow.com/questions/648275/best-way-to-download-large-files-from-web-to-iphone-for-writing-to-disk
timdev
A: 

Make the serverss response XML and bring it into core data that way.

http://code.google.com/p/touchcode/wiki/TouchXML will help you parse the response.

You could also make the server send its response in JSON and use this library, http://code.google.com/p/touchcode/wiki/TouchJSON

Flash84x
A: 

As of now I'm using a php script to querry the database and then just basically scrapping the html data from the php echo calls.

http://ODBCrouter.com/ipad (new) now solves this problem...there are new XCode client-side ODBC libraries and header files that let your Cocoa Touch apps send SQL queries to the server using the industry standard ODBC API and get back binary results directly into your program variables. The client-side ODBC libraries are free, the server side needs to have ODBC Router (and your database vendor's official ODBC driver, both running on a Windows VM or PC somewhere), which winds up costing about the same as a TV (ie, no doubt less expensive than building an XML/JSON infrastructure and fighting to maintain backwards compatibility with every version of your mobile app each time you need to make changes).

AugSoft Tom