WEB开发网
开发学院数据库sqlite Sqlite数据库插入和读取图片数据 阅读

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;  
  
}

上一页  1 2 

Tags:Sqlite 数据库 插入

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接