Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
//
// IfishDBHelper.m
// Ifish
//
// Created by imac on 16/1/26.
// Copyright © 2016年 imac. All rights reserved.
//
#import "IfishDBHelper.h"
@implementation IfishDBHelper
static FMDatabaseQueue *databaseQueue = nil;
+(FMDatabaseQueue *) getDatabaseQueue
{
if (!databaseQueue) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
NSString *dbPath = [documentDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"IfishDB"]];
databaseQueue = [FMDatabaseQueue databaseQueueWithPath:dbPath];
}
return databaseQueue;
}
+ (BOOL) isTableOK:(NSString *)tableName withDB:(FMDatabase *)db
{
BOOL isOK = NO;
FMResultSet *rs = [db executeQuery:@"select count(*) as 'count' from sqlite_master where type ='table' and name = ?",tableName];
while ([rs next])
{
NSInteger count = [rs intForColumn:@"count"];
if (0 == count)
{
isOK = NO;
}
else
{
isOK = YES;
}
}
[rs close];
return isOK;
}
@end