Skip to content

Commit

Permalink
More example
Browse files Browse the repository at this point in the history
  • Loading branch information
ccgus committed Nov 29, 2011
1 parent c0160b3 commit 40258d7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/fmdb.m
Expand Up @@ -902,11 +902,6 @@ int main (int argc, const char * argv[]) {

}

NSLog(@"That was version %@ of sqlite", [FMDatabase sqliteLibVersion]);

[pool release];


FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:dbPath];

FMDBQuickCheck(queue);
Expand Down Expand Up @@ -947,25 +942,44 @@ int main (int argc, const char * argv[]) {
// just mix things up a bit for demonstration purposes.
if (nby % 2 == 1) {
[NSThread sleepForTimeInterval:.1];


[queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
NSLog(@"Starting query %ld", nby);

FMResultSet *rsl = [db executeQuery:@"select * from likefoo where foo like 'h%'"];
while ([rsl next]) {
;// whatever.
}

NSLog(@"Ending query %ld", nby);
}];

}

if (nby % 3 == 1) {
[NSThread sleepForTimeInterval:.1];
}

[queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
NSLog(@"Starting %ld", nby);
NSLog(@"Starting update %ld", nby);
[db executeUpdate:@"insert into likefoo values ('1')"];
[db executeUpdate:@"insert into likefoo values ('2')"];
[db executeUpdate:@"insert into likefoo values ('3')"];
NSLog(@"Ending %ld", nby);
NSLog(@"Ending update %ld", nby);
}];
});

}



NSLog(@"That was version %@ of sqlite", [FMDatabase sqliteLibVersion]);

[pool release];




return 0;
}

0 comments on commit 40258d7

Please sign in to comment.