您好我正在使用cordova开发跨平台应用程序。我有一张这样的桌子
首先,我需要获取数据并将其存储在我的数据库中。其次,当我选择特定客户时,我需要获取该特定记录并在下一页中显示它们。 这是我到目前为止所做的代码, 我创建了一个数据库sqlite和一个表等待列表,
<script>
document.addEventListener("deviceready", onDeviceReady, false);
var st,et;
var currentRow;
function populateDB(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS waitlist13 (id INTEGER PRIMARY KEY AUTOINCREMENT,name, startdatetime,enddatetime)');
}
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
function errorCB1(err) {
alert("Error processing SQL: "+err.code);
}
// Transaction success callback
//
function successCB() {
//var db = window.sqlitePlugin.openDatabase({name:"sqlite"});
//db.transaction(queryDB, errorCB);
alert("table waitlist created");
}
function successCB1() {
window.location="waitlist.html";
}
// Cordova is ready
//
function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase({name:"sqlite"});
db.transaction(populateDB, errorCB, successCB);
}
//Insert query
//
function insertDB(tx) {
tx.executeSql('INSERT INTO waitlist13 (name,startdatetime,enddatetime) VALUES ("' +document.getElementById("clienttextbox").value
+'","'+st+'" ,"'+et+'")');
}
function goInsert() {
console.log("start time");
console.log(st);
var currentdate = new Date();
var enddatetime = currentdate.getHours() + ":"+ currentdate.getMinutes() + ":"+currentdate.getSeconds();
et=enddatetime;
console.log(enddatetime);
console.log("end time");
console.log(et);
var db = window.sqlitePlugin.openDatabase({name:"sqlite"});
db.transaction(insertDB, errorCB1, successCB1);
}
</script>
这里我需要将表结构更改为
CREATE TABLE IF NOT EXISTS waitlist13 (id INTEGER PRIMARY KEY AUTOINCREMENT,name, waitingtime,ticketid,ticketname);
然后我需要在插入中插入多个值,如下所示
tx.executeSql('INSERT INTO waitlist13 (name,waitingtime,ticketid,ticketname) VALUES ("' +document.getElementById("clienttextbox").value
+'","'+st+'" ,"'+et+'")');
我怎样才能从我生成的表中获取值并将它们存储在具有相同ID的数据库中的相应列上?有人可以建议我一个有效的方法吗?有人可以帮助我吗?提前谢谢你......