@@ -83,6 +83,11 @@ void Statement::clearBindings()
83
83
check (ret);
84
84
}
85
85
86
+ int Statement::getIndex (const char * const apName)
87
+ {
88
+ return sqlite3_bind_parameter_index (mStmtPtr , apName);
89
+ }
90
+
86
91
// Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
87
92
void Statement::bind (const int aIndex, const int aValue)
88
93
{
@@ -166,39 +171,39 @@ void Statement::bind(const int aIndex)
166
171
// Bind an int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
167
172
void Statement::bind (const char * apName, const int aValue)
168
173
{
169
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
174
+ const int index = getIndex ( apName);
170
175
const int ret = sqlite3_bind_int (mStmtPtr , index, aValue);
171
176
check (ret);
172
177
}
173
178
174
179
// Bind a 32bits unsigned int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
175
180
void Statement::bind (const char * apName, const unsigned aValue)
176
181
{
177
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
182
+ const int index = getIndex ( apName);
178
183
const int ret = sqlite3_bind_int64 (mStmtPtr , index, aValue);
179
184
check (ret);
180
185
}
181
186
182
187
// Bind a 64bits int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
183
188
void Statement::bind (const char * apName, const long long aValue)
184
189
{
185
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
190
+ const int index = getIndex ( apName);
186
191
const int ret = sqlite3_bind_int64 (mStmtPtr , index, aValue);
187
192
check (ret);
188
193
}
189
194
190
195
// Bind a double (64bits float) value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
191
196
void Statement::bind (const char * apName, const double aValue)
192
197
{
193
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
198
+ const int index = getIndex ( apName);
194
199
const int ret = sqlite3_bind_double (mStmtPtr , index, aValue);
195
200
check (ret);
196
201
}
197
202
198
203
// Bind a string value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
199
204
void Statement::bind (const char * apName, const std::string& aValue)
200
205
{
201
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
206
+ const int index = getIndex ( apName);
202
207
const int ret = sqlite3_bind_text (mStmtPtr , index, aValue.c_str (),
203
208
static_cast <int >(aValue.size ()), SQLITE_TRANSIENT);
204
209
check (ret);
@@ -207,23 +212,23 @@ void Statement::bind(const char* apName, const std::string& aValue)
207
212
// Bind a text value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
208
213
void Statement::bind (const char * apName, const char * apValue)
209
214
{
210
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
215
+ const int index = getIndex ( apName);
211
216
const int ret = sqlite3_bind_text (mStmtPtr , index, apValue, -1 , SQLITE_TRANSIENT);
212
217
check (ret);
213
218
}
214
219
215
220
// Bind a binary blob value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
216
221
void Statement::bind (const char * apName, const void * apValue, const int aSize)
217
222
{
218
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
223
+ const int index = getIndex ( apName);
219
224
const int ret = sqlite3_bind_blob (mStmtPtr , index, apValue, aSize, SQLITE_TRANSIENT);
220
225
check (ret);
221
226
}
222
227
223
228
// Bind a string value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
224
229
void Statement::bindNoCopy (const char * apName, const std::string& aValue)
225
230
{
226
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
231
+ const int index = getIndex ( apName);
227
232
const int ret = sqlite3_bind_text (mStmtPtr , index, aValue.c_str (),
228
233
static_cast <int >(aValue.size ()), SQLITE_STATIC);
229
234
check (ret);
@@ -232,23 +237,23 @@ void Statement::bindNoCopy(const char* apName, const std::string& aValue)
232
237
// Bind a text value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
233
238
void Statement::bindNoCopy (const char * apName, const char * apValue)
234
239
{
235
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
240
+ const int index = getIndex ( apName);
236
241
const int ret = sqlite3_bind_text (mStmtPtr , index, apValue, -1 , SQLITE_STATIC);
237
242
check (ret);
238
243
}
239
244
240
245
// Bind a binary blob value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
241
246
void Statement::bindNoCopy (const char * apName, const void * apValue, const int aSize)
242
247
{
243
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
248
+ const int index = getIndex ( apName);
244
249
const int ret = sqlite3_bind_blob (mStmtPtr , index, apValue, aSize, SQLITE_STATIC);
245
250
check (ret);
246
251
}
247
252
248
253
// Bind a NULL value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
249
254
void Statement::bind (const char * apName)
250
255
{
251
- const int index = sqlite3_bind_parameter_index ( mStmtPtr , apName);
256
+ const int index = getIndex ( apName);
252
257
const int ret = sqlite3_bind_null (mStmtPtr , index);
253
258
check (ret);
254
259
}
0 commit comments