Lines Matching refs:database

26  * This includes managing detail around initialising the schema for the database if
56 -(void)closeConnectionToDatabase:(FMDatabase *)database {
57 if (database == nil) {
63 NSLog(@"Closing database connection: %@", database);
64 BOOL result = [database close];
70 # pragma mark Internal database management functions
73 * Internal call to intiailise the database.
85 FMDatabase *database = [_factory createDatabaseFor:databasePath withError:error];
86 if (database == nil) {
90 if (![database open]) {
92 *error = [FRAError createErrorForLastFailure:database];
96 NSLog(@"Database opened: %@", database);
98 return database;
102 * Internal call to check if the database schema has been initialised.
104 * @return Whether the database has been initialised.
107 FMDatabase* database;
109 database = [self internalGetConnectionWithError:error];
110 if (database == nil) {
114 int query = [self queryDatabaseSchema:database withError:error];
119 if ([self initialiseSchema:database withError:error]) {
130 [self closeConnectionToDatabase:database];
135 * A simple check to indicate if we need to setup the database schema or not.
139 * @param database The database.
141 * @return -1 if there was an error, 0 if the database is not yet setup and 1 if the database is setup.
143 - (int)queryDatabaseSchema: (FMDatabase *) database withError:(NSError *__autoreleasing *)error {
149 FMResultSet* results = [database executeQuery:query];
152 *error = [FRAError createErrorForLastFailure:database];
171 * Internal function to initialise database schema.
172 * @param database The database.
176 - (BOOL)initialiseSchema:(FMDatabase *)database withError:(NSError *__autoreleasing *)error {
182 BOOL result = [database executeStatements:schema];
185 *error = [FRAError createErrorForLastFailure:database];