orbitaloop/WebSqlSync

readme.md questions

Closed this issue · 7 comments

Thanks for putting in the leg-work! I have a few questions to get started:

  1. Where do I put the mysql database information, including password, so that I can upload data from the SQLite database to the server?
  2. initSync: Is this the field to place my mysql URL?
  3. How do I specify "one-way" data transfer to the server? I don't want to replace data in the SQLite database, I just want to transfer it to the mysql database.

Thanks,

Alex

Hello,

  1. You will have to write the server side. In your case (one-way), it's very simple : read the JSON sent by the client, and save it to the database.
  2. no, it's in the server file (the one you need to write, see answer #1). But you will specify here the url of your server
  3. The server code you will write will not return data

Hope this help,

Best regards,

Sam

Thanks! I will work on that script now.

I receive this error:
"TypeError: 'undefined' is not a function (evaluating 'self.db.transaction')" on line 95 of webSqlSync.js.

When I use the database name as a string. This error goes away when I use the sqlite database variable that I initialized the database with.

I have spent all day working on this code, and I'm still stuck with writing the PHP server side file. For the URL, I use, http://www.example.com/upload.php.

Your code adds the following tables to the sqlite database:
"new_elem" and "sync_info". sync_info has 1 entry:
last_syn: 0.

so far, I have:

<?php
$test = $_POST;
print_r($test);
?>

and the php file's output is:

Array
(
)

The issue is that the webSqlSync "syncProgress" outputs 3 lines updated, and there are 3 rows in my sqlite database, so why is the array empty? and shouldn't the array be in JSON format? Also, the self.log file outputs:

Data fetched from the local DB
About to send undefined elements to the server http://www.example.com/upload.php
Object
data: Object
info: Object
__proto__: Object
XHR finished loading: "http://www.example.com/upload.php".
Server answered: 
Object

Therefore, the log says the upload.php server file is receiving the correct "Object".

Sorry for the late answer. Have you found the problem?
If not, I suggest you to check in the JS debugger the array before it's sent to your server. If it's ok, it's a problem in your server code (I don't know PHP, so I can't help you on that part).

The best I could do using basic GoDaddy Linux shared hosting is to retrieve the post data using the command "$x = file_get_contents('php://input');" and then I built a script to put the data into the correct format to get it into mySQL.

Thanks for the script!

great, I am glad that you manage to code your server part.

Hello pls i just stumbled on this library, i am a xomplete newbie to data storage. but i am working on a web app and i want to store my local DB to my server and update the local DB with the new data from the server. pls how can i go about that using websqlsync.js