2012-02-06 60 views
1

不知何故,我的应用程序在Win-Safari中完美工作,但不知何时由PhoneGap包装。这是片段:PhoneGap嵌套executeSql不工作在iPad模拟器

// working db connection 
db.transaction(function(tx) { 
    tx.executeSql('SELECT * FROM tbl', [], function(tx, rs){ 
    // do something with the result 

    tx.executeSql('SELECT * FROM another_tbl', [], function(txTwo, rsTwo){ 
     // do something with the result 

     // further nesting ... 

    }, errorHandler, successHandler); 

    }, errorHandler, successHandler); 
} 

第一个结果集是正确的,我可以console.log()数据。但在此之后,我无法访问第二个嵌套查询的数据。

我没有收到任何错误,而且我的处理程序也没有被调用(例如errorHandler)。有趣的是,它不会导致Safari上的任何问题(赢7)

回答

0

我有这个相同的问题。我已经通过在回调中嵌入另一个事务来处理第一次调用executeSql的操作(我认为这非常丑陋,但它是如此)。

context.db.db.transaction(function(tx) { 
    tx.executeSql("SELECT coalesce(sum(pointsawarded),0) as points from eventhistory ", [], function(tx, res) { 
     alert('h1' + JSON.stringify(res)); 
     context.db.db.transaction(function(txsafe) { 
      txsafe.executeSql("SELECT coalesce(sum(pointsawarded),0) as points2 from eventhistory ", [], function(tx2, res2) { 
       alert('h2' + JSON.stringify(res2)); 
      }); 
     }); 
    }); 
}); 
相关问题