html5 webDatabase 存儲中sql語句執行可嵌套使用

html5 webDatabase 存儲中sql語句執行可嵌套使用,代碼以下:html

var data = window.openDatabase("stu","1.0","stu database",1024*10);
data.transaction(function(tx){
    tx.executeSql("create table if not exists news (id, title)");
    tx.executeSql("select * from news where id = '1'",[],function(tx,result){
        console.log("成功"+result.rows.length);
        if(result.rows.length == 0){
            tx.executeSql("select * from news where id = '123456'",[],function(tx,result){
                console.log("成功2"+result.rows.length);
            })
        }
    })
})
相關文章
相關標籤/搜索