按名称获取sqlite查询结果-目标C

时间:2018-08-22 14:11:13

标签: ios objective-c sqlite

我想按名称而不是按索引获取SQL查询的结果。这是我用来按索引获取结果的代码:

NSString *query = @"SELECT distinct * from contents";

const char* queryUTF8 = [query UTF8String];
sqlite3_stmt *statement;

@autoreleasepool {
    int response = sqlite3_prepare_v2(_database, queryUTF8, -1, &statement, nil);
    if (response == SQLITE_OK) {
        while (sqlite3_step(statement) == SQLITE_ROW) {

            Content * content=[[Content alloc]init];

            //Content Language

            if ( sqlite3_column_type(statement, 0) != SQLITE_NULL ){
                content.ID_ML = sqlite3_column_int(statement, 0);
            }
            else
                content.ID_ML = 0;

            if ( sqlite3_column_type(statement, 1) != SQLITE_NULL ){
                content.MAIN_ID = sqlite3_column_int(statement, 1);
            }
            else
                content.MAIN_ID = 0; 

            .
            .
            .

有可能吗?

0 个答案:

没有答案