javascript - Can we use web SQL local database with PHP? -
i'm creating offline application using web sql local database javascript.
when internet not connected on time entries inserted in local database web sql.
but when connected internet web sql local database synchronize live database , new entries of local database not available in live database inserted automatically.
later on application deployed in phonegap.
here code local database (sql transactions)
open database:
var db = opendatabase('retaurant', '1.0', 'test db', 2 * 1024 * 1024);
new table , insert data table:
var username = "test"; var password = "test"; db.transaction(function (tx) { tx.executesql('create table if not exists user (id integer not null primary key autoincrement , username,password)'); tx.executesql('insert user (username,password) values ("'+username+'","'+password+'")'); });
delete entry database
db.transaction(function (tx) { tx.executesql("delete user id=?", [id], function (tx, results) { }); });
this code local, how can sync database live database using php?
you can't access local db php, can use javascript only.
i think storage total item in local db, or last_id of item in local db.
on page loaded, using ajax compare total of local db , live db. load new item live db , insert local db. or clear local db , load item live db.
hope you!
Comments
Post a Comment