A question on StackOverFlow stated that FMDB doesn't support multiple commands in a single executeUpdate: call and I testified it by reading the code of FMDB.
Here is a little trick to do so:
FMDatabase *db_ = [[FMDatabase alloc] initWithPath:yourPath];
[db_ open];
[db_ beginTransaction];
NSArray *sqlCommands = [DATABASE_TEMPLATE componentsSeparatedByString:@";"];
for (NSString *sql in sqlCommands)
{
[db_ executeUpdate:sql];
}
return [db_ commit];
It is particularly useful when creating many tables, and the string may come from some data files.
沒有留言:
發佈留言