Sorry in advance for sounding like a novice but I'm very new to app development and hope someone can help me!
I'm trying to create an iOS app that will store data locally when offline (i.e. an email address) and once connectivity to the internet is available will persist that data across to a server.
First I created an SQLite database which I done using the db browser tool, and everything for the most part is working the way it should. The app uses Core Data to persist to a SQLite DB.
Next I created a php file that would check for an internet connection then select the SQLite db and it's data then insert that data into a MySQL db.
This is where I got stuck. Am I right in thinking that the data saved in the SQLite db when running on a device is saved in the device's document directory?
If this is true then how do I gain access to it via the php file for it to be persisted over to MySQL server?
Am I missing something? What is the correct way of persisting this data across from the SQLite db on the device to my MySQL server?
Many thanks in advance for any help.
It sounds like you want to store your data in a cookie (the email address), and post to the server when online. You would not need a offline client DB for data as small as an email address.
You could do this with AJAX (Asynchronous Javascript), posting to an awaiting php file based upon a Javascript file.
PHP communicates to MySQL very well with a LAMP/WAMP (Linux/Windows-Apache-MySQL-PHP) type server (or Ios version: IAMP?). With AJAX, you would $_GET or $_POST to the PHP file, and then write the data (after sanitizing) to the MySQL database with either MYSQLI or PDO, preferably with a prepared statement.
To get the data back from the server, you would have another PHP file that could be loaded (again by AJAX) to query MySQL with a simple SELECT statement.
I am suggesting AJAX here because it would not require user interaction to post; you could set a timer to continually check for an internet connection, and post when it does come online. You could also have a similar timer to sync with the server database. Keep in mind, a timer based AJAX will put a constant load on your server, so this may not be too scalable.
Related
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.
I have an application with a local Sqlite database which stores records on the local phone. Now I want to increase functionality and I have come to the conclusion that I need a remote database and server based functionality to make my application more interactive. Also at this juncture I don't want my users to lose data due to this transformation. After research and lookup over the internet I came to know that I can achieve this by writing a web-service which will fetch records row by row and feed into my mySQL database. However I am confused about how to achieve this, do I convert the local databases into XML file(s) and POST them to my PHP where I parse them and feed into mySQL database or there is a better way or rather an API for this? I want a starting point, a heading. Thanks!
As you say, convert local db to XML or JSON and POST it to server. Do not forget use gzip when transfer.
You can upload the db file directly to server. Your db file locate in /data/data/app-package-name/databases. You should parse this db file in server.
I'm currently developing an application in flash that requires me to save data into a remote MySQL database. I use a PHP page to send and receive data from the database and it works fine. However, new updates from the database are not fetched by the PHP page requested by my flash app, even if I reload it. It's like receiving the same old data over and over again. What could possibly wrong with my processes? Can there be a simpler way to access a MySQL through Actionscript without the use of PHP? Thanks!
Check the query in the php page (attach it)
Emulate the request without using Flash - use your browser or a network debug proxy like Charles and see what you get
Are you using Zend_Amf ?
Using flash to directly access a database is something unusual (to me at the very least). It would require authenticating the Flash application against the database server, sending queries up to it and developing a way of parsing the results. It doesn't make things any simpler and adds a great deal of concerns.
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
I never made something similar .
I have a system and i need to relate my data with external data (in another database).
My preference is get these data and create my own tables, but in this case when the other dbs are updated my personal tables will be obsolete.
So, basically i need to synchronize my tables with external tables, or just get the external data values.
I don't have any idea how i can connect and relate data from ten external databases.
I need to check if an user is registered in another websites basically.
Any help?
I am crrently doing something similar.
Easiset way I found is to pull the data in, though I do bi-directional syncronisation in my project you haven't mentionned this so I imagine it's a data pull you are aiming for .
You need to have user accounts on the other servers, and the account needs to be created with an ip instead of 'localhost'. You will connect from your end through mysql client using the ip of distant host instead of the ususal localhost.
see this page for a bit more info.
If, like me you have to interface to different db server types, I recommend using a database abstraction library to ease the managing of data in a seamless way across different sql servers. I chose Zend_db components, used standaline with Zend_config as they Support MySQL and MSSQL.
UPDATE - Using a proxy DB to access mission critical data
Depending on the scope of your project, if the data is not accessible straight from remote database, there are different possibilities. To answer your comment I will tell you how we resolved the same issues on the current project I am tied to. The client has a big MSSQL database that is is business critical application, accounting, invoicing, inventory, everything is handled by one big app tied to MSSQL. My mandate is to install a CRM , and synchronise the customers of his MSSQL mission-critical-app into the CRM, running on MySQL by the way.
I did not want to access this data straight from my CRM, this CRM should not ever touch their main MSSQL DB, I certainly am not willing to take the responsibility of something ever going wrong down the line, even though in theory this should not happen, in practice theory is often worthless. The recommandation I gave (and was implemented) was to setup a proxy database, on their end. That database located on the same MSSQL instance has a task that copies the data in a second database, nightly. This one, I am free to access remotely. A user was created on MSSQL with just access to the proxy, and connection accepted just from one ip.
My scipt has to sync both ways so in my case I do a nightly 'push' the modified records from MSSQL to the crm and 'pull' the added CRM records in the proxy DB. The intern gets notified by email of new record in proxy to update to their MSSQL app. Hope this was clear enough I realize it's hard to convey clearly in a few lines. If you have other questions feel free to ask.
Good-luck!
You have to download the backup (gzip,zip) of the wanted part(or all) of the Database and upload it to the another Database.
Btw. cronjobs wont help you at this point, because you cant have an access to any DB from outside.
Does the other website have an API for accessing such information? Are they capable of constructing one? If so, that would be the best way.
Otherwise, I presume your way of getting data from their database is by directly querying it. That can work to, just make a mysql_connect to their location and query it just like it was your own database. Note: their db will have to be setup to work with outside connections for this method to work.