157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
if (code != SQLITE_OK)
@throw [SL3ClearBindingsFailedException
exceptionWithStatement: self
errorCode: code];
}
- (void)step
{
int code = sqlite3_step(_stmt);
if (code != SQLITE_DONE && code != SQLITE_ROW)
@throw [SL3ExecuteStatementFailedException
exceptionWithStatement: self
errorCode: code];
}
- (void)reset
{
int code = sqlite3_reset(_stmt);
if (code != SQLITE_OK)
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
if (code != SQLITE_OK)
@throw [SL3ClearBindingsFailedException
exceptionWithStatement: self
errorCode: code];
}
- (bool)step
{
int code = sqlite3_step(_stmt);
if (code != SQLITE_DONE && code != SQLITE_ROW)
@throw [SL3ExecuteStatementFailedException
exceptionWithStatement: self
errorCode: code];
return (code == SQLITE_ROW);
}
- (id)objectForColumn: (size_t)column
{
if (column > INT_MAX)
@throw [OFOutOfRangeException exception];
switch (sqlite3_column_type(_stmt, column)) {
case SQLITE_INTEGER:
return [OFNumber numberWithLongLong:
sqlite3_column_int64(_stmt, column)];
case SQLITE_FLOAT:
return [OFNumber numberWithDouble:
sqlite3_column_double(_stmt, column)];
case SQLITE_TEXT:
return [OFString stringWithUTF8String:
(const char *)sqlite3_column_text(_stmt, column)];
case SQLITE_BLOB:
return [OFData
dataWithItems: sqlite3_column_blob(_stmt, column)
count: sqlite3_column_bytes(_stmt, column)];
case SQLITE_NULL:
return [OFNull null];
default:
OF_ENSURE(0);
}
}
- (size_t)columnCount
{
return sqlite3_column_count(_stmt);
}
- (OFString *)nameForColumn: (size_t)column
{
const char *name;
if (column > [self columnCount])
@throw [OFOutOfRangeException exception];
if ((name = sqlite3_column_name(_stmt, column)) == NULL)
@throw [OFOutOfMemoryException exception];
return [OFString stringWithUTF8String: name];
}
- (void)reset
{
int code = sqlite3_reset(_stmt);
if (code != SQLITE_OK)
|