HTML5数据库存储(SQL lite) - 几个问题 [英] HTML5 database storage (SQL lite) - few questions

查看:218
本文介绍了HTML5数据库存储(SQL lite) - 几个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy there,

我在网络上找不到足够的HTML5数据库存储使用示例(CRUD)初级资源

I can't find enough beginner resources on the web about HTML5 database storage usage examples (CRUD)

我以这样的方式打开(创建)我的数据库:

I'm opening(creating) my DB like this:

var db;

$(document).ready(function() 
{

    try
    {
      if (!window.openDatabase) {
            alert('Not Supported -> Please try with a WebKit Browser');
      } else {
          var shortName = 'mydatab';
          var version = '1.0';
          var displayName = 'User Settings Database';
          var maxSize = 3072*1024; //  = 3MB            in bytes 65536
          db = openDatabase(shortName, version, displayName, maxSize);      
          }
    } 
    catch(e) 
    {
      if (e == 2) {

          alert("Invalid database version.");
      } else {
          alert("Unknown error "+e+".");
      }return;
    }
});

问题1:我可以在一个域上创建和使用多少个数据库?
QUESTION 2.如何删除(删除)数据库。 - >我还没有想到这一点。

QUESTION 1: How many databases can i create and use on one domain? QUESTION 2. How to delete (drop) a database. -> i have not figured this out yet.

要创建sql查询,请使用transaction:

To create sql queries you use transaction:

function nullDataHandler(transaction, results) { }
function createTables(db)
{
  db.transaction(function (transaction)
  {
    //first query causes the transaction to (intentionally) fail if the table exists.
    transaction.executeSql('CREATE TABLE people(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL DEFAULT "John Doe", shirt TEXT NOT NULL DEFAULT "Purple");', [], nullDataHandler, errorHandler);
  });
}


$ b <是nullDataHandler涉及到这样做吗?在web上是否有解释executeSql API的文档?参数?

QUESTION 3: How so is the above transaciton failed if a table exists? Is the nullDataHandler involved to do this? Where on the web is there documentation explaining the executeSql API? Arguments?

thx

推荐答案

Web SQL数据库。快速阅读建议:


  1. 没有限制,虽然一旦数据库增加超过一定大小(5MB似乎是默认值)

  2. 在当前规范中没有办法删除数据库。

  3. executeSql ()函数接受一个可选的错误回调参数。

HTML5 Doctor 也有一个很好的介绍。

HTML5 Doctor also has a good introduction.

但是,我建议看看< a href =http://www.w3.org/TR/IndexedDB/ =noreferrer>索引的数据库。 Web SQL本质上已被放弃,因为没有SQL / SQLite的标准。即使微软已经赞成Indexed DB。请参阅关键Web应用标准的共识

Going forward, though, I'd recommend looking at Indexed DB. Web SQL has essentially been abandoned since there is no standard for SQL / SQLite. Even Microsoft has endorsed Indexed DB. See Consensus emerges for key Web app standard.

这篇关于HTML5数据库存储(SQL lite) - 几个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆