如何使用sqlite3_changes()中的$cordovaSQLite函数获取UPDATE,DELETE或INSERT查询的受影响行?
我在执行查询后尝试调用sqlite3_changes()但是sqlite找不到函数sqlite3_changes()
答案 0 :(得分:1)
好的我发现了。
在SQLite查询的返回承诺中有一个rows.affectedRows
属性。
来自docs:
tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
...
使用此功能,您可以检查更新,插入或删除查询会影响的行数。