"DELETE FROM theme WHERE id = ?";
const char kSelectQuery[] =
"SELECT id, version, tool_version, title, description, preview, resolution,"
- " details WHERE id = ?";
+ " details FROM theme WHERE id = ?";
const char kCreateThemeSettingTableQuery[] =
"CREATE TABLE IF NOT EXISTS theme_setting (\n"
" current TEXT,\n"
namespace ttm {
namespace provider {
-DbManager::DbManager(const std::string& db_path) : conn_(db_path, true) {
+DbManager::DbManager(const std::string& db_path) {
+ conn_ = std::make_shared<SQLiteConnection>(db_path, false);
+ if (!conn_->Execute(kCreateThemeTableQuery))
+ LOG(ERROR) << "Failed to create theme table";
+ if (!conn_->Execute(kCreateThemeSettingTableQuery))
+ LOG(ERROR) << "Failed to create theme_setting table";
}
DbManager::~DbManager() {
}
bool DbManager::Insert(const std::string& id, const tizen_base::Bundle& info) {
- std::unique_ptr<SQLiteStatement> stmt = conn_.PrepareStatement(kInsertQuery);
+ std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kInsertQuery);
if (!stmt) {
LOG(ERROR) << "Failed to prepare statement";
return false;
}
bool DbManager::Update(const std::string& id, const tizen_base::Bundle& info) {
- std::unique_ptr<SQLiteStatement> stmt = conn_.PrepareStatement(kUpdateQuery);
+ std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kUpdateQuery);
if (!stmt) {
LOG(ERROR) << "Failed to prepare statement";
return false;
}
bool DbManager::Delete(const std::string& id) {
- std::unique_ptr<SQLiteStatement> stmt = conn_.PrepareStatement(kDeleteQuery);
+ std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kDeleteQuery);
if (!stmt) {
LOG(ERROR) << "Failed to prepare statement";
return false;
}
tizen_base::Bundle DbManager::Select(const std::string& id) {
- std::unique_ptr<SQLiteStatement> stmt = conn_.PrepareStatement(kSelectQuery);
+ std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kSelectQuery);
if (!stmt) {
LOG(ERROR) << "Failed to prepare statement";
return {};
bool DbManager::UpdateCurrentId(const std::string& id) {
std::unique_ptr<SQLiteStatement> stmt =
- conn_.PrepareStatement(kSetThemeQuery);
+ conn_->PrepareStatement(kSetThemeQuery);
if (!stmt) {
LOG(ERROR) << "Failed to prepare statement";
return false;