2011-12-09 7 views
0

私はこのコードを持っている:SQLite web-app、挿入から行を取得しますか?

database.transaction(function(transaction) { 
    transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]); 
}); 

をしかし、私がやりたいことは[]の行を取得することです。 (またはより具体的には行[id])を挿入したばかりです。

トランザクションメソッドはそれ以上の値を返しますか?

UPDATE:

私は、変数、標準の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]); 
    }); 

答えて

0

あなたの挿入後にIDをまっすぐに返す必要があります。

この;select scope_identity()をクエリに追加します。

あなたは、挿入された行のIDを引き出し、そこから必要なものを行うことができるはずです。

+0

select scope_identity()はsqliteではサポートされていませんが、適切な方向に私を指摘している可能性があります:http://stackoverflow.com/questions/5841921/how-to-use-scope-identity-in-sqlite –

関連する問題