JShtml5操作SQLite
发表时间:2020-10-19
发布人:葵宇科技
浏览次数:92
//履行萌芽
$("#btnSQL").tap(function(){
<span style="white-space:pre"> </span>var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
<span style="white-space:pre"> </span>tx.executeSql('CREATE TABLE IF NOT EXISTS testHtml (id unique, contentText)');
<span style="white-space:pre"> </span>tx.executeSql('INSERT INTO testHtml (contentText) VALUES ("insert data test1!")');
});
<span style="white-space:pre"> </span>db.transaction(function(tx){
tx.executeSql('SELECT * FROM testHtml',[],function(tx,result){
<span style="white-space:pre"> </span>var len=result.rows.length;
<span style="white-space:pre"> </span>app.alert(len);
<span style="white-space:pre"> </span>var str=result.rows.item(0);
<span style="white-space:pre"> </span>app.alert(str.contentText);
<span style="white-space:pre"> </span>},null);
<span style="white-space:pre"> </span>});
});








