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

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

作者: masuyan | 来源:发表于2017-06-28 15:43 被阅读8次

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使用】需求:从数据库中 ,查询未读消息的个数

      本文链接:https://www.haomeiwen.com/subject/wdmucxtx.html