Skip to content

A simple extension for FMDB that allows passing NSArrays for MySQL IN Operators

Notifications You must be signed in to change notification settings

mehlkelm/FMDB-InOperator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

FMDB-InOperator

A simple extension for FMDB that allows passing NSArrays for MySQL IN Operators

Pass an array to FMDB using the method

- (BOOL)executeUpdateWithInOperator:(NSString *)sql, ...

like you would pass other NSObjects, but bind it to [?] instead of ?

NSArray *feedIds = @["feed/bla.com/rss.xml", "feed/foo.com/rss.xml", "feed/bar.com/rss.xml"]; 
[database executeUpdateWithInOperator:@"UPDATE feeds SET subscribed = ? WHERE id IN ([?])", @(1), feedIds];

Behind the scenes, this will produce a new NSArray with all arguments and a new Query by replacing any ? with the correct number of ?:

NSArray *arguments = @[@(1), "feed/bla.com/rss.xml", "feed/foo.com/rss.xml", "feed/bar.com/rss.xml"];
@"UPDATE feeds SET subscribed = ? WHERE id IN (?,?,?)"

and call

- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments

About

A simple extension for FMDB that allows passing NSArrays for MySQL IN Operators

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published