Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbQueue 如果是自定义路径和文件名的时候这个queue跟设置自定义不一致 #17

Open
gratefulHeart opened this issue Apr 24, 2017 · 1 comment

Comments

@gratefulHeart
Copy link

  • (FMDatabaseQueue *)dbQueue
    {
    if (!_dbQueue) {
    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:_dbName];
    FMDatabaseQueue *fmdb = [FMDatabaseQueue databaseQueueWithPath:path];
    self.dbQueue = fmdb;
    [_db close];
    self.db = [fmdb valueForKey:@"_db"];
    }
    return _dbQueue;
    }

  • (instancetype)initWithDBName:(NSString *)dbName path:(NSString *)dbPath
    {
    if (!dbName) {
    dbName = @"JQFMDB.sqlite";
    }
    NSString *path;
    if (!dbPath) {
    path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:dbName];
    } else {
    path = dbPath;
    }

    FMDatabase *fmdb = [FMDatabase databaseWithPath:path];

    if ([fmdb open]) {
    self = [self init];
    if (self) {
    self.db = fmdb;
    self.dbName = dbName;
    return self;
    }
    }
    return nil;
    }

@gaojunquan
Copy link
Owner

非常感谢你的反馈, 此bug我已经修复~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants