SQLite에서 행을 가져 오려고하는데 어떤 이유로 첫 행만 꺼내집니다. 입출력에서 SQLite로부터 한 행만 반환됩니까?
-(void)pullNewDataFromSqlite {
NSLog(@"pulling new data");
NSString *fetch_sql = [NSString stringWithFormat:@"SELECT * FROM %@", tableName];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *my_sqlfile = [[paths objectAtIndex:0] stringByAppendingPathComponent:databaseName];
if(sqlite3_open([my_sqlfile UTF8String], &my_dbname) == SQLITE_OK) {
NSLog(@"pulling new data, %@", fetch_sql);
sqlite3_stmt *statement;
NSLog(@"could not prepare statement: %s\n", sqlite3_errmsg(my_dbname));
if(sqlite3_prepare_v2(my_dbname, [fetch_sql UTF8String], -1, &statement, nil) == SQLITE_OK) {
int numberOfColumns = sqlite3_column_count(statement);
//sqlite3_
while (sqlite3_step(statement) == SQLITE_ROW) {
NSLog(@"NEW SQLITE ROW");
int sdcount = sqlite3_column_int(statement, 0);
NSLog(@"NEW SQLITE ROW number, %d", sdcount);
for(int a = 1; a < numberOfColumns; a++) {
char *field = (char *)sqlite3_column_text(statement, a);
NSString *fieldVal = [[NSString alloc]initWithUTF8String:field];
NSString *formatout = [NSString stringWithFormat:@"%@ ", fieldVal];
//match first column with first array
//adding each column info to the array in order
//user id
if(a == 1) {
NSLog(@"a is 1 and the value of the user id is %@", formatout);
[userIdsArray addObject:formatout];
}
//name
if(a == 2) {
NSLog(@"a is 2 and the value of the name id is %@", formatout);
[namesArray addObject:formatout];
}
//picture
if(a == 3) {
NSLog(@"a is 3 and the value of the pic id is %@", formatout);
[picturesArray addObject:formatout];
}
}
//"call sqlite3_finalize to clean up the memory used for the statement, then we return the data."
sqlite3_finalize(statement);
}
}
}
[self closeDB];
if(count < [userIdsArray count]) {
grabFollowers = YES;
}
count = [userIdsArray count];
[self.tableView reloadData];
}
는 또한 다른 두 행을 보여 않지만 어떤 이유는 빈 보여줍니다 여기 내 코드입니다.
당신이 당신의 DB의 내용이 선택을 실행하기 전에 무엇인지 확인하기 위해 SQLite는 데이터 브라우저를 사용 되세요 * 쿼리? –
실제로 성명서를 준비하기 전에 성명서를 준비 할 수 없다는 메시지를 왜 기록합니까? – rmaddy