web sql databases 介绍
websql databases 浏览器端的数据库并不是html5标准规范的一部分,但是它也属于html5 范畴内的技术,有必要深入的学习和了解下。
浏览器端的数据库大部分是基于SQLite (3.1.19),还有一少部分是基于mysql.
支持的浏览器 Safari, Chrome and Opera 10.50)
核心方法
1 openDatabase()
var db = openDatabase('mydb', '1.0', 'my first database', 2 *1024 * 1024);
- Database name
- Version number
- Text description
- Estimated size of database
2 transaction()
db.transaction(function (tx) {
// here be the transaction
// do SQL magic here using the tx object
});
3 executeSql()
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE foo (id unique, text)');
tx.executeSql('SELECT * FROM foo', [], function (tx, results){
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
alert(results.rows.item(i).text);
}
});
});
patchy 拼凑成 specification 规范 recommend 推荐 determine 确定 assume 假设
出处:http://html5doctor.com/introducing-web-sql-databases/
每天一点点积累

浙公网安备 33010602011771号