SLCSqlite 0.1.1

SLCSqlite 0.1.1

Maintained by yang666.



SLCSqlite 0.1.1

  • By
  • WeiKunChao

SLCSqlite

完全面向对象的sqlite数据库api.

Carthage compatible CocoaPods compatible License: MIT

pod 'SLCSqlite'

  1. 引入sqlite3api.

使用

  1. 创建sqlite文件.
SLCSqlite *sqlite = [SLCSqlite sqliteWithFilePath:[NSString stringWithFormat:@"%@/%@",SLCDoucumentPath.library,@"my.sqlite"]];
  1. 创建表. 通过键值的方式,创建字段和对应类型.
[sqlite createTable:@"t_table"
keyValues:@{
@"id":@(SLCSqliteValueTypeInteger | SLCSqliteValueTypeNotNull | SLCSqliteValueTypePrimaryKey | SLCSqliteValueTypeAutoincrement),
@"name":@(SLCSqliteValueTypeText),
@"age":@(SLCSqliteValueTypeInteger)
}];
[sqlite insert:@"t_table"
keyValues:@{
@"name":@"Tom",
@"age":@(20)
}];
[sqlite deleted:@"t_table"
conditions:@{
@"name":SLCConditionEqual(@"Tom")
}];
[sqlite update:@"t_table"
keyValues:@{
@"name":@"Lisa",
@"age":@(18)
} conditions:@{
@"id":SLCConditionEqual(@15),
@"name":SLCConditionEqual(@"Tom")
}];
[sqlite query:@"t_table"
type:SLCQueryTypeAll
conditions:@{
@"id":SLCConditionOrderDesc()
} queryBlock:^(SLCSqliteValue *sqliteValue) {

int ID = [sqliteValue intForIndex:0];
NSString *name = [sqliteValue stringForIndex:1];
int age = [sqliteValue intForIndex:2];
NSLog(@"%d,%@,%d",ID,name,age);
}];