【发布时间】:2014-07-13 15:58:47
【问题描述】:
如果我将每一个(一次一个)放在同一个代码中,第二个会将标题更新为 var testTitle,第一个不会删除与 WHERE 匹配的行/项目。
function deleteTableAItem(e) {
var db3 = Ti.Database.open('thedatabase');
var getTheID = db3.execute('SELECT ID FROM tableA WHERE myIndexColumn=?', e.itemIndex);
var theID = getTheID.fieldByName('ID');
Ti.API.info(tableLinkRef + " " + theID); //they match as intended
var testTitle = "DID I CHANGE?";
db3.execute('DELETE FROM tableB WHERE tableLinkRef=? AND tableARef=?',theID,theTableAItemClicked); // fixed by adding another comparison.
//db3.execute('UPDATE tableB SET titleColumn=? WHERE tableLinkRef=?',testTitle,theID); // this DOES update the titleColumn in matching rows/items when the code is active and the previous is commented out
db3.execute('DELETE FROM tableA WHERE myIndexColumn=?', e.itemIndex); //this deletes the row from the first table. I want to delete the rows I have associated in tableB as well
db3.close();
}
【问题讨论】:
-
您的代码真的是这样吗?如果是这样,它根本不会做任何事情。
-
你需要展示实际代码。
-
停止尝试描述你在做什么,你需要显示代码。
-
会很抱歉。正在努力。
-
TableAItemClicked 的值是多少?它没有传递给函数,所以它是未定义的吗?可能意味着删除将永远找不到要删除的行。
标签: javascript sqlite titanium