调用executeUpdate,屏蔽Could not find index for XXX信息
2014-02-11 13:11
225 查看
我们的app使用FMDatabase操作sqlite3,其中有段代码:
这句sql执行的时候,控制台报了很多Could not find index for XXX。发现如果执行的是insert语句则没有这个现象,只有update语句才会出现
查看了一下FMDatabase的源码:
调用executeUpdate:WithParameterDictionary:方法时,会查找索引,没找到则会打印日志
NSString *sql = @"update tb_users set baseInfo_name = :baseInfo_name, contact_email = :contact_email, baseInfo_image = :baseInfo_image; NSDictionary *data = [datas objectAtIndex:0]; BOOL result = [db executeUpdate:sql withParameterDictionary:mutable];
这句sql执行的时候,控制台报了很多Could not find index for XXX。发现如果执行的是insert语句则没有这个现象,只有update语句才会出现
查看了一下FMDatabase的源码:
// If dictionaryArgs is passed in, that means we are using sqlite's named parameter support if (dictionaryArgs) { for (NSString *dictionaryKey in [dictionaryArgs allKeys]) { // Prefix the key with a colon. NSString *parameterName = [[NSString alloc] initWithFormat:@":%@", dictionaryKey]; // Get the index for the parameter name. int namedIdx = sqlite3_bind_parameter_index(pStmt, [parameterName UTF8String]); FMDBRelease(parameterName); if (namedIdx > 0) { // Standard binding from here. [self bindObject:[dictionaryArgs objectForKey:dictionaryKey] toColumn:namedIdx inStatement:pStmt]; // increment the binding count, so our check below works out idx++; } else { NSLog(@"Could not find index for %@", dictionaryKey); } } }
调用executeUpdate:WithParameterDictionary:方法时,会查找索引,没找到则会打印日志
相关文章推荐
- 精品!一组精美的2014年情人节海报素材
- 今天开始得写一下博客了,总结过去开创未来,以积级的心态迎接挑战!
- 涵盖网站基本使用的正则表达式的验证方法.cs
- Windows server 2008 密码策略更改
- [遇到的问题]java正则表达式
- 开源74个项目
- 纪念我的小蔡电脑助手被百度软件中心收录了~!
- Linux Nvidia 驱动安装与优化
- 计算机视觉相关书籍推荐
- HttpSession常见问题
- Linux上安装Mysql时出现错误 , 包冲突 - 解决
- 64位win7系统,IE10,IE11停止工作,显示urlmon.dll模块故障
- Quora上的一个哥们对mongodb由爱转恨
- 程序代写综合推荐-基于JSP技术的学生宿舍管理系统的设计与实现等程序代写
- App Annie
- Objective-C中的instancetype和id关键字
- 小试ettercap基于arp欺骗的嗅探:测试安卓手机连接wifi的安全性
- Apache DSO模块原理
- PostMessage 窗口无响应
- 《十二生肖运程图》网站欣赏