【发布时间】:2011-08-04 20:24:08
【问题描述】:
1.db的范围是什么?
2.什么时候销毁?
3.如何检查数据库是否存在?
var db = window.openDatabase("Database", "1.0", "MyApp", 900000);
db.transaction(populateDB, errorCB, successCB);
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS PRICE2');
tx.executeSql('CREATE TABLE IF NOT EXISTS PRICE2 (id ,P2_ID,P2_1,P2_2,P2_3,P2_Title,P2_Type,P2_ToType,P2_Up,P2_UpType,PP2_PriceTo,PP2_PriceUp,image)');
var theResults = vData.results;
for(var i=1 ; i < theResults.length ; i++){
tx.executeSql('INSERT INTO PRICE2 (id ,P2_ID,P2_1,P2_2,P2_3,P2_Title,P2_Type,P2_ToType,P2_Up,P2_UpType,PP2_PriceTo,PP2_PriceUp,image) VALUES (' + theResults[i].ID + ', "' + theResults[i].P2_ID + '", "' + theResults[i].P2_1 + '", "' + theResults[i].P2_2 +'", "' + theResults[i].P2_3 +'", "' + theResults[i].P2_Title +'", "' + theResults[i].P2_Type +'", "' + theResults[i].P2_ToType +'", "' + theResults[i].P2_Up +'", "' + theResults[i].P2_UpType +'", "' + theResults[i].PP2_PriceTo +'", "' + theResults[i].PP2_PriceUp +'", "' + theResults[i].image +'")');
}
}
// Transaction error callback
//
function errorCB(tx, err) {
alert("Error processing SQL: "+err);
}
【问题讨论】:
标签: html local-storage