笔记
NSString *path = [self getDBPath];
FMDatabase *db = [FMDatabase databaseWithPath:path];
if ([db open])
{
[db beginTransaction];
BOOL isRollback = NO;
@try {
for (NSString *umqidStr in umqidArray) {
int umqid = [umqidStr intValue];
NSString *updateSql = [NSString stringWithFormat:@"update %@ set %@='%d' where %@='%d'",tableName,@"sstatus",status,@"umqid",umqid];
BOOL a = [db executeUpdate:updateSql];
if (!a) {
NSSLog(@"状态更新失败");
}
else
{
NSSLog(@"sqlite3事务更新消息状态成功")
}
}
} @catch (NSException *exception) {
[db rollback];
} @finally {
if (!isRollback) {
[db commit];
}
}
}
else
{
NSSLog(@"数据库打开失败")
}