Commit 7e776261 authored by Martin Straka's avatar Martin Straka Committed by Karel Slaný

Added database transaction

parent 69df657a
......@@ -619,6 +619,8 @@ bool AccountDb::changeUserName(const QString &oldUserName,
goto fail;
}
beginTransaction();
queryStr = "UPDATE account_info "
"SET key = :newUserName WHERE key = :oldUserName";
if (!query.prepare(queryStr)) {
......@@ -644,13 +646,15 @@ bool AccountDb::changeUserName(const QString &oldUserName,
query.bindValue(":oldUserName", oldUserName);
query.bindValue(":newUserName", newUserName);
if (query.exec()) {
commitTransaction();
return true;
} else {
logErrorNL("Cannot execute SQL query: %s",
query.lastError().text().toUtf8().constData());
goto fail;
}
fail:
rollbackTransaction();
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment