ObjectiveC sqlite3问题 [英] ObjectiveC sqlite3 issue

查看:163
本文介绍了ObjectiveC sqlite3问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在我的iPhone应用程序中更新/插入我的表时遇到问题,因为我有一个TEXT列,当该文本包含'符号时,事情就搞砸了。处理此问题的最佳方法是什么?

I'm finding that I have an issue when updating/inserting into my table in my iPhone app because I have a TEXT column, and when that text includes a ' symbol, things get messed up. What is the best way to handle this?

在使用带撇号的字符串之前,我应该检查吗?有没有一种快速添加格式的方法,可以在每个撇号前添加转义字符?

Should I check before I use a string that has an apostrophe? Is there a quick way to add formatting that will add an escape character in front of each apostrophe?

这个问题是否有意义?大声笑。

Does this question even make sense? lol.

推荐答案

sqlite要求'符号被两个人逃脱'。

sqlite requires the ' symbol to be escape by two ''.

官方sqlite常见问题解答中查看此内容:

(14) How do I use a string literal that contains an embedded single-quote (') character?

The SQL standard specifies that single-quotes in strings are escaped by putting two single quotes in a row. SQL works like the Pascal programming language in the regard. SQLite follows this standard. Example:

    INSERT INTO xyz VALUES('5 O''clock');

这篇关于ObjectiveC sqlite3问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆