// // FMDatabasePool.h // fmdb // // Created by August Mueller on 6/22/11. // Copyright 2011 Flying Meat Inc. All rights reserved. // #import #import "sqlite3.h" @class FMDatabase; @interface FMDatabaseQueue : NSObject { NSString *_path; dispatch_queue_t _queue; FMDatabase *_db; } @property (retain) NSString *path; + (id)databaseQueueWithPath:(NSString*)aPath; - (id)initWithPath:(NSString*)aPath; - (void)close; - (void)inDatabase:(void (^)(FMDatabase *db))block; - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; /* the database is exposed so you can do things like turning on cached statements or setup encryption or whatever. Don't grab the database and start making queries with it. Use the block based access above instead (otherwise you're going to deadlock and cause baby unicorns to cry. */ - (FMDatabase*)database; #if SQLITE_VERSION_NUMBER >= 3007000 // NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock. // If you need to nest, use FMDatabase's startSavePointWithName:error: instead. - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block; #endif @end