예제 #1
0
void SqlQuery::reset_and_clear_bindings()
{
    if (_stmt) {
        SQLITE_DO(sqlite3_reset(_stmt));
        SQLITE_DO(sqlite3_clear_bindings(_stmt));
    }
}
예제 #2
0
bool SqlDatabase::openHelper( const QString& filename, int sqliteFlags )
{
    if( isOpen() ) {
        return true;
    }

    sqliteFlags |= SQLITE_OPEN_NOMUTEX;

    SQLITE_DO( sqlite3_open_v2(filename.toUtf8().constData(), &_db, sqliteFlags, 0) );

    if( _errId != SQLITE_OK ) {
        qDebug() << "Error:" << _error << "for" << filename;
        close();
        return false;
    }

    if( !_db ) {
        qDebug() << "Error: no database for" << filename;
        return false;
    }

    sqlite3_busy_timeout(_db, 5000);

    return true;
}
예제 #3
0
파일: ownsql.cpp 프로젝트: owncloud/client
bool SqlDatabase::openHelper(const QString &filename, int sqliteFlags)
{
    if (isOpen()) {
        return true;
    }

    sqliteFlags |= SQLITE_OPEN_NOMUTEX;

    SQLITE_DO(sqlite3_open_v2(filename.toUtf8().constData(), &_db, sqliteFlags, 0));

    if (_errId != SQLITE_OK) {
        qCWarning(lcSql) << "Error:" << _error << "for" << filename;
        if (_errId == SQLITE_CANTOPEN) {
            qCWarning(lcSql) << "CANTOPEN extended errcode: " << sqlite3_extended_errcode(_db);
#if SQLITE_VERSION_NUMBER >= 3012000
            qCWarning(lcSql) << "CANTOPEN system errno: " << sqlite3_system_errno(_db);
#endif
        }
        close();
        return false;
    }

    if (!_db) {
        qCWarning(lcSql) << "Error: no database for" << filename;
        return false;
    }

    sqlite3_busy_timeout(_db, 5000);

    return true;
}
예제 #4
0
bool SqlDatabase::commit()
{
    if( ! _db ) {
        return false;
    }
    SQLITE_DO(sqlite3_exec(_db, "COMMIT", 0, 0, 0));
    return _errId == SQLITE_OK;
}
예제 #5
0
bool SqlDatabase::transaction()
{
    if( ! _db ) {
        return false;
    }
    SQLITE_DO(sqlite3_exec(_db, "BEGIN", 0, 0, 0));
    return _errId == SQLITE_OK;
}
예제 #6
0
파일: ownsql.cpp 프로젝트: owncloud/client
void SqlQuery::finish()
{
    if (!_stmt)
        return;
    SQLITE_DO(sqlite3_finalize(_stmt));
    _stmt = 0;
    if (_sqldb) {
        _sqldb->_queries.remove(this);
    }
}
예제 #7
0
void SqlDatabase::close()
{
    if( _db ) {
        SQLITE_DO(sqlite3_close(_db) );
        if (_errId != SQLITE_OK) {
            qWarning() << "ERROR When closing DB" << _error;
            Q_ASSERT(!"SQLite Close Error");
        }
        _db = 0;
    }
}
예제 #8
0
파일: ownsql.cpp 프로젝트: owncloud/client
void SqlDatabase::close()
{
    if (_db) {
        foreach (auto q, _queries) {
            q->finish();
        }
        SQLITE_DO(sqlite3_close(_db));
        if (_errId != SQLITE_OK)
            qCWarning(lcSql) << "Closing database failed" << _error;
        _db = 0;
    }
}
예제 #9
0
void SqlQuery::finish()
{
    SQLITE_DO(sqlite3_finalize(_stmt));
    _stmt = 0;
}
예제 #10
0
bool SqlQuery::next()
{
    SQLITE_DO(sqlite3_step(_stmt));
    return _errId == SQLITE_ROW;
}
예제 #11
0
void SqlQuery::reset()
{
    SQLITE_DO(sqlite3_reset(_stmt));
}