GCDB is an extension for FMDB
(https://github.com/ccgus/fmdb).
run GCDB/GCDatabaseDemo.xcodeproj
- Add
pod 'GCDB'
to your Podfile. - Run
pod install
orpod update
. - Import <GCDB/baseDatabase.h>
- Inherit @interface xxx : baseDatabase
- Download all the files in the
GCDB
subdirectory. - Add the source files to your Xcode project.
- Link with required frameworks:
sqlite3
- Import
FMDB
.
######Connect [[GCDataBaseManager defaultDBManager] setDataBaseName:@"xxx"];
######Close [[GCDataBaseManager defaultDBManager] close];
######Execute sql [[baseDatabase sharedInstance] executeUpdateSql:[NSString stringWithFormat:@"insert into chatData (mid,uid,content) values ('%d','323','hahaha')",arc4random() % 10000]];
######InBackground [[baseDatabase sharedInstance] executeSqlInBackground:[NSString stringWithFormat:@"insert into chatData (mid,uid,content) values ('%d','323','hahaha')",arc4random() % 10000]];
######operation database | select [[baseDatabase sharedInstance] executeInDatabase:^(FMDatabase db) { FMResultSet rs = [db executeQuery:@"select mid,uid,content from chatData"]; while ([rs next]) { //NSLog(@"%@",[rs resultDictionary]); deprecated NSLog(@"mid = %@",[rs stringForColumn:@"mid"]); NSLog(@"uid = %@",[rs stringForColumn:@"uid"]); NSLog(@"content = %@",[rs stringForColumn:@"content"]); } [rs close]; }];
This library requires iOS 6.0+
and Xcode 7.0+
.
--- 中文介绍 ==============
GCDB
是一个高性能的sql库。
为了尽量更加自由,没有提供ORM、自动存储等接口
全局队列管理,后期会加入多队列
查看并运行 GCDB/GCDatabaseDemo.xcodeproj
- 在 Podfile 中添加
pod 'GCDB'
。 - 执行
pod install
或pod update
。 - 导入 <GCDB/baseDatabase.h> 。
- 类中继承 @interface xxx : baseDatabase
- 下载 GCDB 文件夹内的所有内容。
- 将 GCDB 内的源文件添加(拖放)到你的工程。
- 添加FMDB相关 并配置依赖
- 导入
GCDB/baseDatabase.h
######连接数据库 [[GCDataBaseManager defaultDBManager] setDataBaseName:@"xxx"];
######关闭数据库 [[GCDataBaseManager defaultDBManager] close];
######执行sql [[baseDatabase sharedInstance] executeUpdateSql:[NSString stringWithFormat:@"insert into chatData (mid,uid,content) values ('%d','323','hahaha')",arc4random() % 10000]];
######后台执行sql [[baseDatabase sharedInstance] executeSqlInBackground:[NSString stringWithFormat:@"insert into chatData (mid,uid,content) values ('%d','323','hahaha')",arc4random() % 10000]];
######操作数据库 | 查询 [[baseDatabase sharedInstance] executeInDatabase:^(FMDatabase db) { FMResultSet rs = [db executeQuery:@"select mid,uid,content from chatData"]; while ([rs next]) { //NSLog(@"%@",[rs resultDictionary]); deprecated NSLog(@"mid = %@",[rs stringForColumn:@"mid"]); NSLog(@"uid = %@",[rs stringForColumn:@"uid"]); NSLog(@"content = %@",[rs stringForColumn:@"content"]); } [rs close]; }];
该项目最低支持 iOS 6.0
和 Xcode 7.0
。