【FMDB使用】需求:从数据库中 ,查询未读消息的个数

SQL语句:select * from notification where isNew = '1'

- (NSInteger)getNotificationNoReadNumber{
NSString *path = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Container.db"];
FMDatabase *database = [FMDatabase databaseWithPath:path]; if ([database open]) { NSString *sql = [NSString stringWithFormat:@"select * from notification where isNew = '1'"]; FMResultSet *set = [database executeQuery:sql]; int num = 0; while ([set next]) { num ++; } [database close]; return num; } else{ NSLog(@"could not open dababase!"); return 0; } }

你可能感兴趣的:(【FMDB使用】需求:从数据库中 ,查询未读消息的个数)