开发者

"IN" expression binding multiple values

开发者 https://www.devze.com 2023-03-25 10:46 出处:网络
I want to migrate user data from old SQLite to new SQLite. First, I query the id of all favorite content via

I want to migrate user data from old SQLite to new SQLite.

First, I query the id of all favorite content via

SELECT id FROM content WHERE favorite = 1

Then I kept all favorite content id in NSMutableArray like this

NSMutableArray *favContentIds = [NSMutableArray array];  
while (sqlite3_step(compiledStatement) == SQLITE_ROW) {  
    NSInteger favContentId = sqlite3_column_int(compiledStatement, 0);  
    [favContentIds addObject:[NSNumber numberWithInteger:favContentId]];  
}

Now I want to bind favContentIds in update statement

UPDATE content SET favorite = 1 WHERE id IN ?  
开发者_开发知识库

I tried sqlite3_bind_text but it doesn't work. Do I have to convert favContentIds to NSString with UTF8String?

Any help would be appreciated.

0

精彩评论

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