【发布时间】:2010-11-02 17:10:40
【问题描述】:
我想开始使用 html5 的客户端数据库功能,但我不知道从哪里获得好的介绍/教程/操作方法。我多年来一直在编写 (x)html 代码,所以我对“这里是 <head> 元素”类型的介绍不太感兴趣;我想了解 html5 中的 new 内容,尤其是客户端数据库。有什么建议吗?
【问题讨论】:
-
如果您觉得回复有用,请勾选已回答:)
标签: html
我想开始使用 html5 的客户端数据库功能,但我不知道从哪里获得好的介绍/教程/操作方法。我多年来一直在编写 (x)html 代码,所以我对“这里是 <head> 元素”类型的介绍不太感兴趣;我想了解 html5 中的 new 内容,尤其是客户端数据库。有什么建议吗?
【问题讨论】:
标签: html
亚历克斯, 我写了一个详细的方法:http://wecreategames.com/blog/?p=219 - 包括要下载的源代码。这里有一些sn-ps:
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 的示例,请参阅博客文章,以及展示如何在一些浏览器上测试它的视频。
【讨论】:
【讨论】: