diff options
-rw-r--r-- | hkutil/database.h | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/hkutil/database.h b/hkutil/database.h index 0914047..619ba86 100644 --- a/hkutil/database.h +++ b/hkutil/database.h | |||
@@ -113,18 +113,20 @@ namespace hatkirby { | |||
113 | { | 113 | { |
114 | sqlite3_stmt* tempStmt; | 114 | sqlite3_stmt* tempStmt; |
115 | 115 | ||
116 | if (sqlite3_prepare_v2( | 116 | int ret = sqlite3_prepare_v2( |
117 | ppdb_.get(), | 117 | ppdb_.get(), |
118 | query.c_str(), | 118 | query.c_str(), |
119 | query.length(), | 119 | query.length(), |
120 | &tempStmt, | 120 | &tempStmt, |
121 | NULL) != SQLITE_OK) | 121 | NULL); |
122 | |||
123 | ppstmt_type ppstmt(tempStmt); | ||
124 | |||
125 | if (ret != SQLITE_OK) | ||
122 | { | 126 | { |
123 | throw sqlite3_error("Error writing to database", ppdb_.get()); | 127 | throw sqlite3_error("Error writing to database", ppdb_.get()); |
124 | } | 128 | } |
125 | 129 | ||
126 | ppstmt_type ppstmt(tempStmt); | ||
127 | |||
128 | if (sqlite3_step(ppstmt.get()) != SQLITE_DONE) | 130 | if (sqlite3_step(ppstmt.get()) != SQLITE_DONE) |
129 | { | 131 | { |
130 | throw sqlite3_error("Error writing to database", ppdb_.get()); | 132 | throw sqlite3_error("Error writing to database", ppdb_.get()); |
@@ -157,18 +159,20 @@ namespace hatkirby { | |||
157 | 159 | ||
158 | sqlite3_stmt* tempStmt; | 160 | sqlite3_stmt* tempStmt; |
159 | 161 | ||
160 | if (sqlite3_prepare_v2( | 162 | int ret = sqlite3_prepare_v2( |
161 | ppdb_.get(), | 163 | ppdb_.get(), |
162 | query_str.c_str(), | 164 | query_str.c_str(), |
163 | query_str.length(), | 165 | query_str.length(), |
164 | &tempStmt, | 166 | &tempStmt, |
165 | NULL) != SQLITE_OK) | 167 | NULL); |
168 | |||
169 | ppstmt_type ppstmt(tempStmt); | ||
170 | |||
171 | if (ret != SQLITE_OK) | ||
166 | { | 172 | { |
167 | throw sqlite3_error("Error writing to database", ppdb_.get()); | 173 | throw sqlite3_error("Error writing to database", ppdb_.get()); |
168 | } | 174 | } |
169 | 175 | ||
170 | ppstmt_type ppstmt(tempStmt); | ||
171 | |||
172 | int i = 1; | 176 | int i = 1; |
173 | for (const column& c : columns) | 177 | for (const column& c : columns) |
174 | { | 178 | { |
@@ -191,18 +195,20 @@ namespace hatkirby { | |||
191 | { | 195 | { |
192 | sqlite3_stmt* tempStmt; | 196 | sqlite3_stmt* tempStmt; |
193 | 197 | ||
194 | if (sqlite3_prepare_v2( | 198 | int ret = sqlite3_prepare_v2( |
195 | ppdb_.get(), | 199 | ppdb_.get(), |
196 | queryString.c_str(), | 200 | queryString.c_str(), |
197 | queryString.length(), | 201 | queryString.length(), |
198 | &tempStmt, | 202 | &tempStmt, |
199 | NULL) != SQLITE_OK) | 203 | NULL); |
204 | |||
205 | ppstmt_type ppstmt(tempStmt); | ||
206 | |||
207 | if (ret != SQLITE_OK) | ||
200 | { | 208 | { |
201 | throw sqlite3_error("Error preparing query", ppdb_.get()); | 209 | throw sqlite3_error("Error preparing query", ppdb_.get()); |
202 | } | 210 | } |
203 | 211 | ||
204 | ppstmt_type ppstmt(tempStmt); | ||
205 | |||
206 | int i = 1; | 212 | int i = 1; |
207 | for (const binding& value : bindings) | 213 | for (const binding& value : bindings) |
208 | { | 214 | { |