开发者

iphone sqlite quotes problem

开发者 https://www.devze.com 2023-02-08 01:51 出处:网络
I have a problem with a following sqlite query: sql = [NSString stringWithFormat:@\"Insert into table_name(height)values(\'%@\')\",heightarray];

I have a problem with a following sqlite query:

sql = [NSString stringWithFormat:@"Insert into table_name(height)values('%@')",heightarray];

I am getting heightarray from XML, the value of heightarray is:

array =  ( "5'0\"-5'3\"",
           "5'4\"-5'8\"",
           "5'9开发者_StackOverflow\"-6'0\"" )

The \" is added implicitly for some reason, I don't know why?

It is causing problem. please help.


try to use

sql = [NSString stringWithFormat:@"Insert into table_name(height)values(?)"];

and then use

sqlite3_bind_text

If you're using sqlite try this wrapper it helps a lot https://github.com/ccgus/fmdb

There are detailed examples how to use it.

0

精彩评论

暂无评论...
验证码 换一张
取 消