I think its easier to use json istead of xml, this saves a lot of time
in javascript, and PHP have built in functions to convert to json.

Example:

In your php script:
echo json_encode($dataarray); // $dataarray contains all your db data

In your gearscode:
 //data from server is saved in serverresponse
 //
 try {
       eval("dataarr="+serverresponse);

      }
   catch (ex) {
      alert("Error: No valid data found..");
      return;
    }


var dbcount=0;
var reply="no reply";
var db ;
db= google.gears.factory.create('beta.database');
if (db) {
  db.open('yourdatabase');
  db.execute('begin');
  db.execute('drop table if exists yourtable');
  db.execute('create table if not exists yourtable' +
           ' (yourfield1, yourfield2, yourfield3, primary key
(yourfield1))');
  for (x in dataarr)
    {
    db.execute('insert into yourtable values(?,?,?)',
        [dataarr[x].yourfield1,dataarr[x].yourfield2,dataarr
[x].yourfield3];
    dbcount++;
    //if (dbcount%100==0)
      //wp.sendMessage(dbcount+" record(s) added....",
message.sender);
    }
  }
db.execute('commit');
db.close();
reply=dbcount+" record(s) added from main DB, finished";


A link to a tutorial using XML:
http://www.onlamp.com/pub/a/onlamp/2007/06/28/the-power-of-google-gears-part-1.html


On Feb 8, 2:37 am, TML <[email protected]> wrote:
> Just to clarify...I mean programmatically, not a one off with a tool.
> When the user goes online on their pda the data is imported into the
> locally held sqlite db.
>
> On Feb 8, 1:34 am, TML <[email protected]> wrote:
>
> > Hello,
>
> > I have a MySQL DB on web server. I have php page that extracts the
> > data from table and creates an XML file.
>
> > Now, I need to know how to import that data in the XML file into the
> > Gears sqlite DB on PDA?
>
> > Any suggestions?
>
> > Thanks,
> > TML

Reply via email to