Phonegap插入查询+无法正常工作

时间:2012-12-13 06:33:36

标签: ios sqlite cordova

我正在使用phoneagap框架进行APP开发。 在phonegap中插入查询:

tx.executeSql('insert into "'+gAppConfig.configTable+'" (key , value) values(uniqueId,"'+uniqueId+'"),(serverURL,"'+serverURL+'")' , querySuccess, errorQuery);

这不起作用,任何人都可以告诉我可能出错的地方。感谢。

1 个答案:

答案 0 :(得分:1)

我想您已经在数据库中创建了一个表,并且您已将其命名为“tablename”,其中包含2列“id”& “的serverURL”;其中“id”是主键。

试试这个:

   Iquery = "INSERT INTO 'tableName' VALUES(null, "+serverURL+");";
   tx.executeSql(
      Iquery,
      null,
      function(){ /* to do on success, or you may just set it as "null" */},
      function(){ /* to do on error, or you may just set it as "null" */});

或者你可以试试这个:

 tx.executeSql("INSERT INTO tableName(id, serverURL) VALUES (?,?)",
        [null, serverURL], // these are the variables to insert
        function(){ /* to do on success, or you may just set it as "null" */},
        function(){ /* to do on fail, or you may just set it as "null" */});

您可以参考原始documentation of cordova了解更多信息。

相关问题