首页 > 数据库技术 > 详细

html5_websql

时间:2016-05-16 14:17:57      阅读:236      评论:0      收藏:0      [点我收藏+]
var db = openDatabase(‘mydb‘, ‘1.0‘, ‘Test DB‘, 2 * 1024 * 1024);
 var msg;
 db.transaction(function (tx) {
    tx.executeSql(‘CREATE TABLE IF NOT EXISTS LOGS (id unique, log)‘);
    tx.executeSql(‘INSERT INTO LOGS (id, log) VALUES (1, "foobar")‘);
    tx.executeSql(‘INSERT INTO LOGS (id, log) VALUES (2, "logmsg")‘);
    msg = ‘<p>Log message created and row inserted.</p>‘;
  console.log(msg);
 });
 db.transaction(function (tx) {
    tx.executeSql(‘SELECT * FROM LOGS‘, [], function (tx, results) {
    var len = results.rows.length, i;
     msg = "<p>Found rows: " + len + "</p>";
     console.log(msg);
    for (i = 0; i < len; i++){
       msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
       console.log(msg);
     }
 }, null);});

html5_websql

原文:http://www.cnblogs.com/shidengyun/p/5497823.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!