码迷,mamicode.com
首页 > 移动开发 > 详细

iOS中sqlite版本号

时间:2016-09-17 19:13:06      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
https://github.com/yapstudios/YapDatabase/blob/master/YapDatabase/YapDatabase.m
技术分享?
技术分享?

+ (NSString *)sqliteVersionUsing:(sqlite3 *)aDb
{
    sqlite3_stmt *statement;
    
    int status = sqlite3_prepare_v2(aDb, "SELECT sqlite_version();", -1, &statement, NULL);
    if (status != SQLITE_OK)
    {
        YDBLogError(@"%@: Error creating statement! %d %s", THIS_METHOD, status, sqlite3_errmsg(aDb));
        return nil;
    }
    
    NSString *version = nil;
    
    status = sqlite3_step(statement);
    if (status == SQLITE_ROW)
    {
        const unsigned char *text = sqlite3_column_text(statement, SQLITE_COLUMN_START);
        int textSize = sqlite3_column_bytes(statement, SQLITE_COLUMN_START);
        
        version = [[NSString alloc] initWithBytes:text length:textSize encoding:NSUTF8StringEncoding];
    }
    else
    {
        YDBLogError(@"%@: Error executing statement! %d %s", THIS_METHOD, status, sqlite3_errmsg(aDb));
    }
    
    sqlite3_finalize(statement);
    statement = NULL;
    
    return version;
}

iOS中sqlite版本号

标签:

原文地址:http://www.cnblogs.com/huahuahu/p/iOS-zhongsqlite-ban-ben-hao.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!