SL3PreparedStatement: Add -[row{Array,Dictionary}]
FossilOrigin-Name: 7a52167702278bdd7c5f3aac48771cba8ac5a77abfac4d1664b05a507fe8236e
This commit is contained in:
parent
5967ebf3b7
commit
9f22b628f2
3 changed files with 53 additions and 15 deletions
|
@ -41,10 +41,12 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
- (void)bindWithDictionary:
|
||||
(OFDictionary OF_GENERIC(OFString *, id) *)dictionary;
|
||||
- (void)clearBindings;
|
||||
- (bool)step;
|
||||
- (id)objectForColumn: (size_t)column;
|
||||
- (size_t)columnCount;
|
||||
- (OFString *)nameForColumn: (size_t)column;
|
||||
- (bool)step;
|
||||
- (OFArray *)rowArray;
|
||||
- (OFDictionary OF_GENERIC(OFString *, id) *)rowDictionary;
|
||||
- (void)reset;
|
||||
@end
|
||||
|
||||
|
|
|
@ -217,6 +217,34 @@ bindObject(SL3PreparedStatement *statement, int column, id object)
|
|||
return [OFString stringWithUTF8String: name];
|
||||
}
|
||||
|
||||
- (OFArray *)rowArray
|
||||
{
|
||||
size_t count = [self columnCount];
|
||||
OFMutableArray *array = [OFMutableArray arrayWithCapacity: count];
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
[array addObject: [self objectForColumn: i]];
|
||||
|
||||
[array makeImmutable];
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
- (OFDictionary OF_GENERIC(OFString *, id) *)rowDictionary
|
||||
{
|
||||
size_t count = [self columnCount];
|
||||
OFMutableDictionary *dictionary =
|
||||
[OFMutableDictionary dictionaryWithCapacity: count];
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
[dictionary setObject: [self objectForColumn: i]
|
||||
forKey: [self nameForColumn: i]];
|
||||
|
||||
[dictionary makeImmutable];
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
- (void)reset
|
||||
{
|
||||
int code = sqlite3_reset(_stmt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue