在哪里可以了解如何将html5用于客户端数据库应用程序? [英] Where can I learn about how to use html5 for client-side database apps?

查看:78
本文介绍了在哪里可以了解如何将html5用于客户端数据库应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始使用html5的客户端数据库功能,但我不知道在哪里可以找到一个好的介绍/教程/操作方法。我多年来一直在编码(x)html,所以我对这里的< head> 元素类型的介绍并不感兴趣;我想了解一般html5中的 new 是什么,特别是客户端db。有什么建议吗?

I would like to begin using the client-side database functionality of html5, but I don't know where to go for a good introduction/tutorial/how-to. I've been coding (x)html for years and years, so I'm not so much interested in a "here's the <head> element" type of introduction; I want to learn about what's new in html5 in general, and client-side db in particular. Any suggestions?

推荐答案

Alex,
我写了一个详细的方法,如何在 http://wecreategames.com/blog/?p=219 - 包括要下载的源代码。这里有几个片段:

Alex, I wrote up a detailed method of how to do it at: http://wecreategames.com/blog/?p=219 - including source code to download. Here's a few snippets:

function picsInitDatabase() {
    try {
        if (!window.openDatabase) {
            console.log('Databases are not supported in this browser');
        } else {
            var shortName = 'picsGeoDB';
            var version = '1.0';
            var displayName = 'Pictures Geotagged database';
            var maxSize = 5000000; // in bytes
            picsDB = openDatabase(shortName, version, displayName, maxSize);
            console.log("Database is setup: "+picsDB);
        }
    } catch(e) {
        // Error handling code goes here.
        if (e == 2) {
            // Version number mismatch.
            console.log("Invalid database version.");
        } else {
            console.log("Unknown error "+e+".");
        }
        return;
    } 
}

这是更新表格的函数:

function picsUpdateTables(dataID) { 
    picsDB.transaction(
        function (transaction) {
            var p = data[dataID];
            transaction.executeSql("INSERT INTO geopictures (id, secret, server, farm, title, latitude, longitude, accuracy, datetaken, ownername) VALUES (?,?,?,?,?,?,?,?,?,?);",
            [p.id, p.secret, p.server, p.farm, p.title, p.latitude, p.longitude, p.accuracy, p.datetaken, p.ownername] );
            transaction.executeSql("INSERT INTO photodata (picid, encodedtext) VALUES (?, ?)", [p.id, serializeCanvasByID(p.id)] );
        }
    );  
}

有关如何执行SQL SELECTS的示例和视频,请参阅博客文章展示如何在几个浏览器上测试它。

See the blog post for examples of how to do SQL SELECTS, and a video showing how to test it on a few browsers.

这篇关于在哪里可以了解如何将html5用于客户端数据库应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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