Sqlite数据库插入和读取图片数据
2013-01-14 16:02:12 来源:WEB开发网核心提示:读取图片:// Load images from data base with given image url - (NSData*) LoadImagesFromSql: (NSString*) imageLink { NSData* data = nil; NSString* sqlite
读取图片:
// Load images from data base with given image url - (NSData*) LoadImagesFromSql: (NSString*) imageLink { NSData* data = nil; NSString* sqliteQuery = [NSString stringWithFormat:@"SELECT IMAGE FROM IMAGES WHERE URL = '%@'", imageLink]; sqlite3_stmt* statement; if( sqlite3_prepare_v2(articlesDB, [sqliteQuery UTF8String], -1, &statement, NULL) == SQLITE_OK ) { if( sqlite3_step(statement) == SQLITE_ROW ) { int length = sqlite3_column_bytes(statement, 0); data = [NSData dataWithBytes:sqlite3_column_blob(statement, 0) length:length]; } } // Finalize and close database. sqlite3_finalize(statement); return data; }
更多精彩
赞助商链接