html5µԣǾ˱ش洢û飬html5߽µĻʱ
濴web ݿɣ½ݿ⣡
var db = window.openDatabase("mydata", "1.0","ݿ",20000);
//window.openDatabase("ݿ", "汾","ݿ",ݿС);
if(db)
alert("½ݿɹ");
ֻǴԵĽһ뿴ϸ˵ԲοĽ̳̣Ҳˣ
ݿأ
db.transaction(function(tx) {
tx.executeSql("CREATE TABLE test (id int UNIQUE, mytitle TEXT, timestamp REAL)");
});
½ݱݿͨdb.transaction()ʵֵģٿĴɣ
¼
db.transaction(function(tx) {
tx.executeSql("INSERT INTO test (mytitle, timestamp) values(?, ?)", ["WEB Database", new Date().getTime()], null, null);
});
¼¼
db.transaction(function(tx) {
tx.executeSql("update test set mytitle=? where mytitle = 'fsafdsaf'",['xp'],null,null);
});
ѯ¼
db.transaction(function(tx) {
tx.executeSql("SELECT * FROM test", [],
function(tx, result) {
for(var i = 0; i < result.rows.length; i++){
document.write('' + result.rows.item(i)['mytitle'] + '
');
}
}, function(){
alert("error");
});
});
ɾ
db.transaction(function(tx) {
tx.executeSql("DROP TABLE test");
})
ʵݿǾǼڶѣ˽sqlģԲοվĽ̳̣
鿴ݿǷɹأgoogleṩ˺ԻĹߣͼƬ
ݿͽܵ