如果“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" );
}
}
答案 0 :(得分:1)
您是否尝试过这样的查询:
make
注意:请使用传递给函数的空数组tx.executeSql("Update EventSoccer SET VacantSpaces = VacantSpaces -1, NoPeople = NoPeople + 1
WHERE Title = '" + title + "' AND VacantSpaces > 0",
[],
successJoin,
errorCB
);
作为第二个参数来清理输入。