本文整理汇总了C++中Global::setDatabaseVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ Global::setDatabaseVersion方法的具体用法?C++ Global::setDatabaseVersion怎么用?C++ Global::setDatabaseVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Global
的用法示例。
在下文中一共展示了Global::setDatabaseVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tempTable
//*****************************************
//* This class is used to connect to the
//* database.
//*****************************************
DatabaseConnection::DatabaseConnection(QString connection)
{
dbLocked = Unlocked;
this->connection = connection;
QLOG_DEBUG() << "SQL drivers available: " << QSqlDatabase::drivers();
QLOG_TRACE() << "Adding database SQLITE";
conn = QSqlDatabase::addDatabase("QSQLITE", connection);
QLOG_TRACE() << "Setting DB name";
conn.setDatabaseName(global.fileManager.getDbDirPath("nixnote.db"));
QLOG_TRACE() << "Opening database";
if (!conn.open()) {
QLOG_ERROR() << "Error opening database: " << conn.lastError();
exit(16);
}
if (connection == "nixnote")
global.db = this;
QLOG_TRACE() << "Preparing tables";
// Start preparing the tables
configStore = new ConfigStore(this);
dataStore = new DataStore(this);
NSqlQuery tempTable(this);
// tempTable.exec("pragma cache_size=8096");
// tempTable.exec("pragma page_size=8096");
tempTable.exec("pragma busy_timeout=50000");
tempTable.exec("pragma journal_mode=wal");
// tempTable.exec("pragma SQLITE_THREADSAFE=2");
if (connection == "nixnote") {
tempTable.exec("pragma COMPILE_OPTIONS");
QLOG_DEBUG() << "*** SQLITE COMPILE OPTIONS ***";
while (tempTable.next()) {
QLOG_DEBUG() << tempTable.value(0).toString();
}
int value = global.getDatabaseVersion();
if (value < 2) {
QLOG_DEBUG() << "*****************";
QLOG_DEBUG() << "Upgrading Database";
DatabaseUpgrade dbu;
dbu.fixSql();
}
global.setDatabaseVersion(2);
}
QLOG_TRACE() << "Creating filter table";
tempTable.exec("Create table if not exists filter (lid integer)");
tempTable.exec("delete from filter");
QLOG_TRACE() << "Adding to filter table";
tempTable.exec("insert into filter select distinct lid from NoteTable;");
QLOG_TRACE() << "Addition complete";
tempTable.finish();
}