1.
特殊符号导致sql语句执行失败
今天测试报了个bug,对比数据库后才发现这个小问题,记下
//特殊符号导致数据库操作失败 NSString *sql = [NSString stringWithFormat:@"delete from %@ where %@ = '%@'",MXQDTable,MXQDColumnURL,itemInfo.url]; Log:delete from table where url = 'http://m.baidu.com/s?from=1097d_w1&word=www.stg'.com' //因为',导致sql语句执行失败,改为用?,就会识别特殊字符 NSString *sql = [NSString stringWithFormat:@"delete from %@ where %@ = ?",MXQDColumnURL]; [dbHandler executeUpdate:sql,itemInfo.url];2.