将NSString绑定到sqlite3 sql语句

时间:2011-03-15 21:08:14

标签: iphone sql sqlite

你们能告诉我如何将nsstring绑定到sqlite3 sql语句吗?

NSString *date = @"test date";
char const *sqlStatement = sqlite3_mprintf("UPDATE facts SET alreadyRead = '%q' WHERE id=%d", date, factId);

%q不适用于字符串 %d适用于nsinteger

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

NSString *date = @"test date";
char const *sqlStatement = sqlite3_mprintf("UPDATE facts SET alreadyRead = '%q' WHERE id=%d", [date UTF8String], factId);