Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想确保我以正确的方式格式化子句,就像在查询中一样。例如,我有以下代码:
int count = [[[MyDBObject query] whereWithFormat:@"url like '%%@%'", mySearchString] count];
我的问题是:我是否为 like 子句使用了正确的格式?
谢谢你,编码愉快:)
因为字符串格式化程序讨厌这个,所以我们必须适应并制作一个特殊的参数类型,所以我们可以将它识别为一个相似的参数。因为字符串格式是其中的一部分,但是随后将参数提供给查询,格式变得非常混乱,您必须对转义字符非常有创意。
所以你需要的是dbMakeLike()
dbMakeLike()
例子:
whereWithFormat:@"lower(text) LIKE %@“, dbMakeLike(searchString.lowercaseString)
谢谢