问题在iPhone上运行的应用程序的PhoneGap

问题在iPhone上运行的应用程序的PhoneGap

本文介绍了问题在iPhone上运行的应用程序的PhoneGap SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的移动应用程序中使用PhoneGap的用HTML5编写的。应用程序的某些部分使用SQL数据库,像这样的:

I have mobile app written in HTML5 using PhoneGap. Some parts of the app make use of SQL database, like this:

db = window.openDatabase("my_app_database", "1.0", "Description of my database about 50 chars long", 1000000);

$.get('db/app_data.dat',function(result){
  var data = $.parseJSON(result);
  if (!data) {
    alert('Data error');
    return false;
  }
  db.transaction(function(tx){
    tx.executeSql('DROP TABLE IF EXISTS table_a');
    tx.executeSql('DROP TABLE IF EXISTS table_b');
    tx.executeSql('CREATE TABLE table_a (id INTEGER,name,html)');
    tx.executeSql('CREATE TABLE table_b (id_a INTEGER, id_b INTEGER)');
  });
  db.transaction(function(tx){
    $.each(data.item, function(i, v){
      tx.executeSql('INSERT INTO table_a(id, name,html) VALUES (?,?,?)',[v.id, v.name, v.html]);
    });
  });
});

在Android这个工作完全正常,没有问题。但在iPhone(4.0,4.2),它不会在所有的工作。你有什么想法,为什么在PhoneGap的这个标准使用SQL数据库将导致iPhone上的任何种类的麻烦吗?是否有一些限制需要注意的?例如。数据库名称限制,数据库大小限制或查询的限制?

On Android this works perfectly fine with no problem. But on iPhone(4.0, 4.2) it doesn't work at all. Do you have any ideas why this standard use of SQL database on PhoneGap would cause any kind of trouble on iPhone ? Are there some limits to be aware of ? E.g. database name limit, database size limit or query limits ?

编辑:不知道这是否是相关的,但我使用的PhoneGap v按照这个程序0.9.5.1现在

Don't know if it is relevant, but I am using PhoneGap v. 0.9.5.1 in this app right now.

推荐答案

好吧,我终于想通了这个问题。似乎有某种形式的SQL查询长度的限制,这是不记录。至少我还没有找到它的任何地方。我的INSERT查询为190个字符长(询问问题的简单在这里我缩短了在给定的例子查询),当我不断尝试和测试,我也试图使列名较短。我不知道此限制的确切数字,但与130个字符长度的查询工作的罚款。

Ok, I've finally figured out this problem. There seems to be some kind of SQL-query-length limit, which is not documented. At least I haven't found it anywhere. My INSERT query was 190 characters long (for the simplicity of asking question here I have shortened the query in the given example) and when I kept trying and testing, I also tried to make column names shorter. I don't know the exact number of this limit, but query with the length of 130 characters worked fine.

这篇关于问题在iPhone上运行的应用程序的PhoneGap SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 04:08