I had developed an Application in android in which I fetch some data from MYSQL database and do some operations on it and store it in SQLite.Now I want to send all the data stored in SQLite to MYSQL.I know i need to use JSON there.I will store my result in Cursor say Cursor c="select * from emp" (just example) now how i will parse this cursor into String to send it to the php page? and how i will decode it there?? Please help me.
Asked
Modified
14 years, 3 months ago
Viewed
2k times
Part
of PHP and Mobile Development Collectives
4
-
Where is the SQLite database, and where is the MySQL database? You want to do this once? Or is this some regular part of your application?Brad– Brad2011-08-10 16:59:24 +00:00Commented Aug 10, 2011 at 16:59
-
It is very hard to answer this question, we need more information. The title sounds as if you want to to database replication (i.e. store EVERYTHING in the client DB in the server DB - every table, every row). On the other hand, if you just want to send SOME data from the client to the server for some reason, then it has nothing to do with the actual DBs - it is just a question of how to transfer data, and then, yes, JSON would be a possible option as the transmission format.Tom– Tom2011-08-10 17:20:41 +00:00Commented Aug 10, 2011 at 17:20
-
@Brad it is a regular part of my Application,SQLitie Db is inside my phone and MySQL is at the webserver.require_once– require_once2011-08-10 18:30:38 +00:00Commented Aug 10, 2011 at 18:30
-
@Tom I want to send every data mean each row to the webserver means select * from the table and send it to MysqLrequire_once– require_once2011-08-10 18:31:35 +00:00Commented Aug 10, 2011 at 18:31
Add a comment
|
1 Answer
If what you are asking is how you can encode data and send it to php as GET parameter you could use the following:
$encoded=base64_encode(serialize($data)) and then call example.com/?data=$encoded where $data could be the query result from $data=$sth->fetchAll(PDO::FETCH_ASSOC);
and on the receiving end: $decoded=unserialize(base64_decode($_GET['data']))
but this will limit you to about 2K of data.
If you can use POST, then use POST.
1 Comment
require_once
I didint get it.My data will be stored in a cursor when i retrieve all records from Db.How i will send it to the php?