SQLite Web应用程序,从插入中获取行?
我有这样的代码:
database.transaction(function(transaction) {
transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]);
});
但我想做的是获取 row[]; (或者更具体地说 row[id])来自我刚刚插入的内容。
交易方法是否返回更多值?
更新:
我用变量插入它,标准 sqlite-webapp 方式。
var todoInput = $('#todo').val();
var descriptionInput = $('#description').val();
var myDate = new Date();
myDate.getMonth() + 1 + '/' + myDate.getDate() + '/' + myDate.getFullYear();
database.transaction(function(transaction) {
transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]);
});
I have this code:
database.transaction(function(transaction) {
transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]);
});
But what I want to do is to get the row[]; (or more specifically row[id]) from what I just inserted.
Does the transaction method return any more values?
UPDATE:
I inserted it with variables, standard sqlite-webapp way.
var todoInput = $('#todo').val();
var descriptionInput = $('#description').val();
var myDate = new Date();
myDate.getMonth() + 1 + '/' + myDate.getDate() + '/' + myDate.getFullYear();
database.transaction(function(transaction) {
transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在插入后立即返回 id。
将此
;selectscope_identity()
添加到您的查询中。那么你应该能够提取插入行的 id 并从那里执行你想要的操作。
you need to return the id straight after your insert.
add this
;select scope_identity()
to your query.then you should be able to pull out the id of the inserted row and do what you want from there.