【发布时间】:2016-07-31 23:10:43
【问题描述】:
图片上传后,我需要帮助在 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");
}
感谢您帮助更正我的代码。
【问题讨论】:
-
在 querySuccessFUS 里面你可以检查 results.rowsAffected 的值,如果它是
-
我已经在表
foto上插入了数据,只需要更新每张上传图片的行。