Skip to content

Commit 977c7cd

Browse files
author
ChrisCaixx
authored
Update README.md
1 parent e401b44 commit 977c7cd

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
# GKDatabase
1+
####基于SQLite3轻量级封装,一行代码实现增删改查
2+
3+
```objc
4+
// 打开数据库
5+
[[GKDatabaseManager sharedManager]openDatabase]
6+
7+
// 创建表格
8+
// 默认表为为类名,主键为t_default_id
9+
[[GKDatabaseManager sharedManager] creatTableWithClassName:[Person class]];
10+
11+
// 插入数据
12+
Person * p = [[Person alloc]init];
13+
p.name =@"花菜ChrisCai";
14+
p.age = 100;
15+
[[GKDatabaseManager sharedManager] insertDataFromObject:p]
16+
17+
// 查询指定表内数据
18+
NSArray * persons = [[GKDatabaseManager sharedManager] selecteDataWithClass:[Person class]];
19+
20+
// 模糊查找
21+
22+
// 枚举类型含义
23+
typedef NS_ENUM(NSInteger ,GKDatabaseSelectLocation){
24+
/// 以某个字符串开头
25+
GKDatabaseSelectStartWithString = 0,
26+
/// 包含有某个字符串
27+
GKDatabaseSelectRangOfString,
28+
/// 以某个字符串结尾
29+
GKDatabaseSelectEndWithString
30+
};
31+
// 查询Person表格中所有年龄包含8的
32+
NSArray * resultArr = [[GKDatabaseManager sharedManager] selectObject:[Person class] propertyName:@"age" type:GKDatabaseSelectRangOfString content:@"8"];
33+
34+
// 更新数据
35+
// 将Student表中所有age = 100对应的记录name都改为Chris
36+
[[GKDatabaseManager sharedManager] updateObject:[Student class] oldValues:@[@"age = 100"] conditionType:QueryTypeAND newValues:@[@"name = Chris"]]
37+
38+
// 指定删除
39+
// 删除Person表中所有age>50的记录
40+
[[GKDatabaseManager sharedManager] deleteObject:[Person class] withString:@"age > 50"]
41+
```
42+
更多详细使用,请看Demo~,

0 commit comments

Comments
 (0)