gpt4 book ai didi

ios - 列数返回零

转载 作者:行者123 更新时间:2023-11-29 02:29:29 24 4
gpt4 key购买 nike

我正在尝试创建从 sqlite 数据库读取的循环,但列计数始终返回零。列=0

sqlite3_stmt    *statement;

NSString *querySQL = @"SELECT * FROM Animations";

const char *query_stmt = [querySQL UTF8String];

if (sqlite3_prepare_v2(localDB,query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
int columns = sqlite3_data_count(statement);
NSLog(@"Columns: %d",columns);

while(sqlite3_step(statement) == SQLITE_ROW)
{
for (int i=1;i<columns;i++)
{
NSString *st0 = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, i)];
NSLog(@"%@",st0);
}
}
}

else
{
NSLog(@"%s","Error on SQLITE_OK");
}

最佳答案

https://www.sqlite.org/c3ref/data_count.html

The sqlite3_data_count(P) routine returns 0 if the previous call to sqlite3_step(P) returned SQLITE_DONE. 

尝试将数据计数放在 sqlit3_step 语句之后(在 while 循环内)

关于ios - 列数返回零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27087171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com