【问题标题】:how to mark an sqlite transaction as complete in phonegap如何在phonegap中将sqlite事务标记为完成
【发布时间】:2012-08-15 10:40:33
【问题描述】:

我有以下代码:

  db.transaction(
    function runQuery(tx) {
      tx.executeSql(
        'delete from meetings where id='+id
      );
      log('delete from meetings where id='+id);
    },
    function(e) {
      log('failed to delete from database: '+e.code);
    },
    function() {
      log('meeting deleted from db: '+id);
      setTimeout(callback, 1);
    } 
  );

在回调中,我查询了会议表,我刚刚删除的行仍然存在。这是超时时间是 1、1000 还是其他。

我如何告诉 phonegap 请关闭事务以便数据库正确同步?

【问题讨论】:

  • 如果我尝试添加 tx.executeSql('commit');到 runQuery 函数,我从 sqlite 收到错误“未授权”

标签: android sqlite cordova


【解决方案1】:

对于任何有同样问题的人,这对我有用。 http://osdir.com/ml/phonegap/2012-12/msg00429.html

db.transaction(function(tx) {tx.executeSql("Delete FROM myTable where id=?",[1]);}, errorDeleteCB,successDeleteCB);

我看到的唯一真正区别是使用 ?和 [1]

【讨论】:

    猜你喜欢
    • 2014-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-31
    • 2014-12-16
    • 2015-12-18
    • 1970-01-01
    相关资源
    最近更新 更多