Forráskód Böngészése

Fixed [FMDatabase openWithFlags:] so it does not reopen the db unnecessarily

This is just copying what was done in [FMDatabase open:] by return YES if the database already exists. This solves a problem with issue #211 where any connection changes being made in the [FMDatabasePoolDelegeate databasePool: didAddDatabase:] would just get reset as the database would be reopened on each pool call. Likely inefficent as well.
DanOrange 12 éve
szülő
commit
294d54c1e0
1 módosított fájl, 4 hozzáadás és 0 törlés
  1. 4 0
      src/FMDatabase.m

+ 4 - 0
src/FMDatabase.m

@@ -112,6 +112,10 @@ - (BOOL)open {
 
 #if SQLITE_VERSION_NUMBER >= 3005000
 - (BOOL)openWithFlags:(int)flags {
+    if (_db) {
+        return YES;
+    }
+
     int err = sqlite3_open_v2([self sqlitePath], &_db, flags, NULL /* Name of VFS module to use */);
     if(err != SQLITE_OK) {
         NSLog(@"error opening!: %d", err);