Permalink
Browse files

Implemented BLOB retrieval through EGODatabase.

  • Loading branch information...
1 parent dbd9789 commit 6b9663023e71f23162a0da7fa266d92258d1a8d6 Grzegorz Adam Hankiewicz committed Oct 20, 2010
Showing with 18 additions and 1 deletion.
  1. +5 −1 EGODatabase.m
  2. +3 −0 EGODatabaseRow.h
  3. +10 −0 EGODatabaseRow.m
View
@@ -277,7 +277,11 @@ - (EGODatabaseResult*)executeQuery:(NSString*)sql parameters:(NSArray*)parameter
while(sqlite3_step(statement) == SQLITE_ROW) {
EGODatabaseRow* row = [[EGODatabaseRow alloc] initWithDatabaseResult:result];
for(x=0;x<columnCount;x++) {
- if(sqlite3_column_text(statement,x) != NULL) {
+ if (SQLITE_BLOB == sqlite3_column_type(statement, x)) {
+ [row.columnData addObject:[NSData
+ dataWithBytes:sqlite3_column_text(statement,x)
+ length:sqlite3_column_bytes(statement,x)]];
+ } else if (sqlite3_column_text(statement,x) != NULL) {
[row.columnData addObject:[[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement,x)] autorelease]];
} else {
[row.columnData addObject:@""];
View
@@ -50,6 +50,9 @@
- (NSString*)stringForColumn:(NSString*)columnName;
- (NSString*)stringForColumnIndex:(int)columnIdx;
+- (NSData*)dataForColumn:(NSString*)columnName;
+- (NSData*)dataForColumnIndex:(int)columnIndex;
+
- (NSDate*)dateForColumn:(NSString*)columnName;
- (NSDate*)dateForColumnIndex:(int)columnIdx;
View
@@ -93,6 +93,16 @@ - (NSString*)stringForColumnIndex:(int)columnIndex {
return [columnData objectAtIndex:columnIndex];
}
+- (NSData*)dataForColumn:(NSString*)columnName {
+ int columnIndex = [self columnIndexForName:columnName];
+ if (columnIndex < 0 || columnIndex == NSNotFound) return nil;
+ return [columnData objectAtIndex:columnIndex];
+}
+
+- (NSData*)dataForColumnIndex:(int)columnIndex {
+ return [columnData objectAtIndex:columnIndex];
+}
+
- (NSDate*)dateForColumn:(NSString*)columnName {
int columnIndex = [self columnIndexForName:columnName];
if(columnIndex == -1) return nil;

0 comments on commit 6b96630

Please sign in to comment.