0
我正在制作phonegap应用程序并在其中使用ydn-db。ydn-db - 如何检查数据库是否存在
问题是我不想一直做db = new ydn.db.Storage('db-name')
,因为它创建了一个新的数据库。有没有办法检查我的数据库是否已经存在?
我正在制作phonegap应用程序并在其中使用ydn-db。ydn-db - 如何检查数据库是否存在
问题是我不想一直做db = new ydn.db.Storage('db-name')
,因为它创建了一个新的数据库。有没有办法检查我的数据库是否已经存在?
你也可以用来检查下面的代码。
function onDeviceReady(){ var db = window.openDatabase(“Database”,“1.0”,“PhoneGap Demo”,200000); db.transaction(populateDB,errorCB,successCB); }
// Populate the database
//
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
}
嗨,你使用sqllite或websql? – user1374
Umm ... ydn-db提供了一个indexeddb,websql和localstorage的包装。在我的情况下,我使用websql – AdityaSaxena
如果它能为你工作,请接受答案..谢谢 – user1374