/* 先向数据库插入此人的热度 */ NSString *strSql=[[NSString alloc]initWithFormat:@"%@%@%@", @"select * from cloud_contacts where uid='",compUser.uId,@"'"]; NSLog(@"查询此人热度的sql是:%@",strSql); self.mysqlite = [[sqliteHelper alloc]init]; if([self.mysqlite openDatabase:@"ucab_db.db"]) { //先查询此人的热度 NSMutableArray *tempCompUsers = [self.mysqlite getCloudUsersBySQL:strSql]; CompUser *tempCompUser = [tempCompUsers objectAtIndex:0]; int iHotNumber; if (tempCompUser.hotNumber!=nil) { iHotNumber = [tempCompUser.hotNumber intValue]; ++iHotNumber; //多加一次 NSLog(@"%@的热度指数是:%i",compUser.cn,iHotNumber); }else { iHotNumber = 0; } [self.mysqlite closeDatabase]; //如果此处不对数据库进行关闭,将无法完成下一步的数据插入操作! if([self.mysqlite openDatabase:@"ucab_db.db"]){ //将最新的热度指数插入数据库 NSString *hotNumber = [NSString stringWithFormat:@"%i",iHotNumber]; NSString *strUpdateSql=[[NSString alloc]initWithFormat:@"%@%@%@%@%@", @"update cloud_contacts set hotNumber='",hotNumber,@"' where uid='",compUser.uId,@"'"]; NSLog(@"插入热度指数的sql是:%@",strUpdateSql); [self.mysqlite execSql:strUpdateSql]; [self.mysqlite closeDatabase]; } }