GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - coderflower/GKDatabase

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
GKDatabase.xcodeproj
GKDatabase.xcodeproj
 
 
GKDatabase
GKDatabase
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 

Repository files navigation

###基于SQLite3轻量级封装,一行代码实现增删改查

// 打开数据库
[[GKDatabaseManager sharedManager]openDatabase]

// 创建表格
// 默认表为为类名,主键为t_default_id
[[GKDatabaseManager sharedManager] creatTableWithClassName:[Person class]];

// 插入数据
Person * p = [[Person alloc]init];
p.name =@"花菜ChrisCai";
p.age = 100;
[[GKDatabaseManager sharedManager] insertDataFromObject:p]

// 查询指定表内数据
NSArray * persons = [[GKDatabaseManager sharedManager] selecteDataWithClass:[Person class]];

// 模糊查找

// 枚举类型含义
typedef NS_ENUM(NSInteger ,GKDatabaseSelectLocation){
    /// 以某个字符串开头
    GKDatabaseSelectStartWithString = 0,
    /// 包含有某个字符串
    GKDatabaseSelectRangOfString,
    /// 以某个字符串结尾
    GKDatabaseSelectEndWithString
};
// 查询Person表格中所有年龄包含8的
NSArray * resultArr = [[GKDatabaseManager sharedManager] selectObject:[Person class] propertyName:@"age" type:GKDatabaseSelectRangOfString content:@"8"];

// 更新数据
// 将Student表中所有age = 100对应的记录name都改为Chris
[[GKDatabaseManager sharedManager] updateObject:[Student class] oldValues:@[@"age = 100"] conditionType:QueryTypeAND  newValues:@[@"name = Chris"]]

// 指定删除
// 删除Person表中所有age>50的记录
[[GKDatabaseManager sharedManager] deleteObject:[Person class] withString:@"age > 50"]

###新增方法

/**
 *  从表格中移除完全匹配对象属性的行
 *
 *  @param object 模型对象
 *
 *  @return 删除结果
 */
- (BOOL)deleteObject:(id)object; 
// 执行指自定义的sql语句,并返回结果
- (BOOL)executeSqlString:(NSString *)sqlString;

更多使用详情,请看Demo~ 原理篇请看这里简书地址

About

No description, website, or topics provided.

Resources

Readme
Activity

Stars

101 stars

Watchers

3 watching

Forks

20 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.