我需要帮助在图片上传后在Cordova Android中传递SQLite更新变量。这是我的代码。
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Sent = " + r.bytesSent);
var kodes = r.response;
upSuccess(kodes); // variable to be sent
}
function upSuccess() {
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(populateDBFUS, errorCBFUS, successCBFUS);
}
function populateDBFUS(tx4UF) {
tx4UF.executeSql('CREATE TABLE IF NOT EXISTS foto (id INTEGER PRIMARY KEY AUTOINCREMENT, kode, urut, file_name, status)');
}
function successCBFUS(tx4UF) {
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(queryDBFUS, errorCBFUS);
}
function queryDBFUS(tx4UF) {
tx4UF.executeSql('UPDATE foto SET status = "1" ', [], querySuccessFUS, errorCBFUS); // need to add where statement with variable from upSuccess(kodes)
}
function querySuccessFUS(tx4UF, results) {
myApp.alert("Upload OK");
}
function errorCBFUS(tx4UF, results) {
myApp.alert("Fail Update");
}
感谢您帮助纠正我的代码。
答案 0 :(得分:0)
查询的变量可以按如下方式传递:
tx4UF.executeSql("UPDATE foto SET status = "1" WHERE file_name = '"+filename+"' ;", [], querySuccessFUS, errorCBFUS);
请尝试,希望这有帮助。