Nee*_*hah 5 lastinsertid cordova android-sqlite
我正在创建一个应用程序,我在表中插入数据.在表中插入数据后,我想得到该行的id,以便我可以根据它进行进一步的操作.我试图使用sqlite的last_insert_rowid()函数,但没有找到运气.任何人都可以告诉哪个是最后一个插入行id的最佳方法.任何想法都表示赞赏.提前致谢.
你可以在这样的表上得到最后一个插入的id -
tx.executeSql("INSERT INTO profile('name','label','list_order','category') values(?,?,?,?)",
[currentProfile.name, currentProfile.label, currentProfile.list_order, currentProfile.category],
function(tx, results){
var lastInsertId = results.insertId; // this is the id of the insert just performed
},
failCB
)
Run Code Online (Sandbox Code Playgroud)
该results.insertId在的WebSQL类似于mysql_insert_id()MySQL中-
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
Run Code Online (Sandbox Code Playgroud)