sqlite3_stmt *statement;
NSString *query = [NSString stringWithFormat:@"SELECT * FROM voiceMemoTable WHERE folder_number = %d ORDER BY file_date, file_time DESC", [currentFolderNumber integerValue]];
NSLog(@"query : %s", [query UTF8String]);
if(sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, NULL) == SQLITE_OK)
{
while(sqlite3_step(statement) == SQLITE_ROW)
{
NSString *fileName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
NSString *filePath = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
VoiceMemo *currentVoiceMemo = [[VoiceMemo alloc]initWithName:fileName Path:filePath];
[currentFolder addObject:currentVoiceMemo];
}
NSLog(@"### STATUS : success to get current folder %@ from database", currentFolderNumber);
NSLog(@"current folder %@", currentFolder);
}
else
{
NSLog(@"@@@ ERROR : failed to prepare statement in getFolderFromDatabase. ERROR CODE : %s", sqlite3_errmsg(database));
}
これがコードです。と、
2012-12-14 17:45:05.409 Rivo Recorder[9927:907] query : SELECT * FROM voiceMemoTable WHERE folder_number = 0 ORDER BY file_date, file_time DESC
2012-12-14 17:45:05.416 Rivo Recorder[9927:907] ### STATUS : success to get current folder 0 from database
2012-12-14 17:45:05.423 Rivo Recorder[9927:907] current folder (
)
これがログです。
where クエリが適用されない理由がわかりません。データベースは間違っていません。folder_number 列の値が 0 の正しいデータがあります。
クエリの構文について間違っていますか?