mirror of
https://github.com/zealdocs/zeal.git
synced 2024-11-27 11:44:56 +03:00
util: Implement SQLiteDatabase::execute()
This method relies on sqlite3_exec(), but currently doesn't allow to retrieve data.
This commit is contained in:
parent
a994817308
commit
b3fc62e2ae
@ -124,6 +124,28 @@ bool SQLiteDatabase::next()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SQLiteDatabase::execute(const QString &sql)
|
||||
{
|
||||
if (m_db == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lastError.clear();
|
||||
|
||||
char *errmsg = nullptr;
|
||||
const int rc = sqlite3_exec(m_db, sql.toUtf8(), nullptr, nullptr, &errmsg);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
if (errmsg) {
|
||||
m_lastError = QString::fromUtf8(errmsg);
|
||||
sqlite3_free(errmsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant SQLiteDatabase::value(int index) const
|
||||
{
|
||||
Q_ASSERT(index >= 0);
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
bool prepare(const QString &sql);
|
||||
bool next();
|
||||
|
||||
bool execute(const QString &sql);
|
||||
|
||||
QVariant value(int index) const;
|
||||
|
||||
QString lastError() const;
|
||||
|
Loading…
Reference in New Issue
Block a user