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。
我对查询的语法错了吗?