问题
I have a WebSQL database, and am trying to connect to a PHP script, and dump that database into another one on the server.
How do I format the javascript / jquery in order to do that correctly?
I guess I am asking, how do I dump all of my data in my tables into my PHP script, so that it can update and insert the data into another database on the server?
I have no clue where to even begin with this.
回答1:
The terminology in this question is a little confusing. If you're trying to copy the database from one location to another on the same server, you would only use PHP at most. This could also be done with just your sql administration.
If you are attempting to copy the database to a "Web SQL" database on a client (not a server), I've found a round-a-bout sort of way to accomplish this. I say round-a-bout because in my case I had to copy the database from the server to local client files (aka cross domain). In short:
1) Use PHP to create a json_encode version of your database from the server, using fwrite to create a .json file on the server
2) Using a php proxy to deliver the json data, make a jquery ajax call to the proxy, for the .json file you created
3) Use javascript to store the JSON data into the client's "web sql" database.
来源:https://stackoverflow.com/questions/12343867/websql-database-upload