【发布时间】:2016-07-28 07:16:32
【问题描述】:
我只希望在“VacantSpaces”不为 0 时执行更新查询。换句话说,一旦特定事件不再有任何空格,“VacantSpaces”将为 0,因此用户应该无法加入,号码不会变为-1、-2等。
但是我不太确定该怎么做。
JavaScript 函数:
function updateEvent(title) {
db = window.openDatabase("SoccerEarth", "2.0", "SoccerEarthDB", 2 * 1024 * 1024);
db.transaction(function(tx) {
tx.executeSql("Update EventSoccer SET VacantSpaces = VacantSpaces -1, NoPeople = NoPeople + 1
WHERE Title = '" + title + "'",
[],
successJoin,
errorCB
);
});
function successJoin() {
navigator.notification.alert("You have joined the event!",
null,
"Information", "ok");
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#page4" );
}
}
【问题讨论】:
标签: javascript sql sqlite cordova