blob: a3503af3f6c6989e1edc04ec521f7e9414d28e17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "compiledsql.h"
CompiledSQL::CompiledSQL(SQLite::Database& db):
m_stmt{},
m_db{db},
m_isSelect{}
{
}
void CompiledSQL::init(const std::string& stmt)
{
if (m_stmt) {
m_stmt->reset();
} else {
if (stmt.starts_with("SELECT ")) {
m_isSelect = true;
} else {
m_isSelect = false;
}
m_stmt = std::make_shared<SQLite::Statement>(m_db, stmt);
}
}
bool CompiledSQL::execute()
{
if (m_isSelect) {
return m_stmt->executeStep();
} else {
return m_stmt->exec();
}
}
|