#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(m_db, stmt); } } bool CompiledSQL::execute() { if (m_isSelect) { return m_stmt->executeStep(); } else { return m_stmt->exec(); } }