???????????????????
???????????? ???????[ 2014/7/10 13:58:52 ] ????????????????? ?????
????????????????У????????д?????洢???????????????webkit???????????У????????????WEBSQL?????????????????????????php?????????????????????????д??????Web Storage?洢???????????????????????????????????????豸?????????????API????????????????Web Storage?洢???????5MB??????洢?????????????δ??????洢???????????????????????????????Web SQL???????????SQLite???????????????????????????executeSql()???????????????JavaScript???????????????????????????????????????????????
???????????????
???????????WebDb???б????????洢???????????????????????????????????API??openDatabase????????????????????
????openDatabase(DbName??DBVersion??DBDescribe??DBSize??Callback());
????????????????????????汾???????????????С????????λ??????????????????е?????????
????????????????????????????
????1??openDatabase?????????????????????????????????????????
????2??transaction???????????????????????????????????????
????3??executeSql?????????????????????SQL?????
??????????????????????????????
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Database API</title>
</head>
<body>
<script type="text/javascript">
//??????????????????£???????λ??
//"C:/Users/Administrator/AppData/Local/Google/Chrome/User Data/Default/databases/1";
if(window.openDatabase){
//???test??????????????????????????
var db = openDatabase("test"?? "1.0"?? "Database test"?? 1024 * 1024);
//????????????
var sql = 'CREATE TABLE if not exists "student" ('+
'"_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL??'+
'"name" TEXT NOT NULL??'+
'"age" TEXT??'+
'"mark" TEXT)';
//д?????????
var sql2 = 'insert into student (name??age??mark) values ("frog"??1??"nice frog") ';
//??????????
var sql3 = 'select * from student';
//??????????÷?
var sql4 = 'insert into student (name??age??mark) values (:name??:age??:mark)';
/**
* ??????????php???????????÷?
* $stmt = $dbh->prepare("INSERT INTO REGISTRY (name?? value) VALUES (:name?? :value)");
* $stmt->bindParam(':name'?? $name);
* $stmt->bindParam(':value'?? $value);
*/
var name = 'aron';
var age = 29;
var mark = 'hello world';
exec(sql??function(rs){
//????????????????
//??????????????????????
exec(sql2??function(rs){
exec(sql3??function(rs){
console.log(rs.rows.item(0))
})
exec2(sql4??[name??age??mark])
})
});
//????????????????????
function exec(sql??callback){
db.transaction(function(tx){
//?м????[]?????????????а??
tx.executeSql(sql??[]??function(tx??rs){
//success
callback && callback(rs);
}??function(tx??msg){
//error
console.log(msg);
});
});
}
//????????
function exec2(sql??para??callback){
para = para || [];
db.transaction(function(tx){
tx.executeSql(sql??para??function(tx??rs){
//success
callback && callback(rs);
}??function(tx??msg){
//error
console.log(msg);
});
});
}
}
</script>
</body>
</html>
|
???????????????html????????????????????????????????????е?????
???????????
?????????????????3??????????Firefox???????????????????????????????SQLite?????п????indexDB????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11